1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

How to create new page dynamically in php

Discussion in 'PHP' started by Lalit Panwar, Jun 3, 2014.

  1. #1
    i want to create new page dynamically when i clicked on submit button.
    SEMrush
     
    Lalit Panwar, Jun 3, 2014 IP
    SEMrush
  2. PoPSiCLe

    PoPSiCLe Illustrious Member

    Messages:
    4,623
    Likes Received:
    722
    Best Answers:
    152
    Trophy Points:
    470
    #2
    WHAT do you want to make? A completely new file? How is this file gonna be accessed? Does it need to be a complete webpage, ie with a <html> and <head> with linked files, or does it just need to contain a container for content, which then will be pulled via another page? You need to give us a bit more info for us to be able to help.
    However, doing the basic thing is just plugging the variables from the form/input you have, into a file - look at fwrite() or similar.
     
    PoPSiCLe, Jun 3, 2014 IP
  3. Lalit Panwar

    Lalit Panwar Member

    Messages:
    6
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    31
    #3
    i want to show Name, age, about etc.. field on new page when user click on submit button.(php)

    i created a form with name , age, about, occupation field. now i want show all field on new page. plz help me

    plz check this link www.howtobe-model.com/create-profile.php . in this i want to show all field data in new page when form has been submitted.
     
    Lalit Panwar, Jun 3, 2014 IP
  4. PoPSiCLe

    PoPSiCLe Illustrious Member

    Messages:
    4,623
    Likes Received:
    722
    Best Answers:
    152
    Trophy Points:
    470
    #4
    That's not really creating a new page - that's just showing the info from the form on an already created page. Just make the page, call it from the forms action-property, and echo the $_POST variables where you want them.
     
    PoPSiCLe, Jun 4, 2014 IP
  5. cerahil

    cerahil Active Member

    Messages:
    72
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    63
    #5
    You can print all form fields in the file you specified in form action
    Like this:
    <form action="submit.php">
    Code (markup):
    And in submit.php file you can print this data with following code:

    <?php
    foreach($_POST as $k=>$v){
      echo $k." = ".$v.'<br/>';
    }
    
    ?>
    Code (markup):
     
    cerahil, Jun 5, 2014 IP
  6. Dev_Navi

    Dev_Navi Greenhorn

    Messages:
    4
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    21
    #6
    Example:
    <?php

    if(isset($_POST['submit']))
    {
    if(isset($_POST['address']))
    {
    $address=$_POST['address'];
    $age=$_POST['age'];​
    }​
    header("location:next.php?address=".$address."&age=".$age);​
    }​
    ?>
    <form name="whatever" action="<?php echo $_SERVER['PHP_SELF'];?>" method="post">
    <input name="address" type="text" />
    <input name="age" type="text" />
    <input type="submit" name="submit" />
    </form>

    Now on the next.php page

    <p> your address is <b> <?=$_REQUEST['address'];?> </b>
     
    Last edited: Jun 9, 2014
    Dev_Navi, Jun 9, 2014 IP
  7. PoPSiCLe

    PoPSiCLe Illustrious Member

    Messages:
    4,623
    Likes Received:
    722
    Best Answers:
    152
    Trophy Points:
    470
    #7
    Uhm - that's blatantly wrong. $_POST doesn't automatically get put into $_SESSION - god forbid.
    Your code doesn't work, at all. Try again. Or, better yet, don't.
     
    PoPSiCLe, Jun 9, 2014 IP
  8. Dev_Navi

    Dev_Navi Greenhorn

    Messages:
    4
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    21
    #8

    It works now. before it was foolishness.

    Thanks :)
     
    Dev_Navi, Jun 9, 2014 IP
  9. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #9
    Don't mean to be rude, but it's still a little foolish. Why wouldn't you send the data directly via POST to the next page? Constructing a new URL and sending a redirect is not necessary.

    Plus, $_SERVER['PHP_SELF'] makes the form vulnerable to XSS injections. Just leave the action attribute blank or put the actual file name there.
     
    nico_swd, Jun 9, 2014 IP
  10. Neetuchow

    Neetuchow Greenhorn

    Messages:
    5
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    21
    #10
    Hi lalit,
    First of all, Naming the page and url
    Name: use a concatenation for ex: I did break it in many chuncks for demo purposes.
    $begin_url= "<a href=\"index" ;
    $p=".php";
    $end="\">" ;
    $file_name="myPage";
    $a="</a><br>";
     
    Neetuchow, Jun 13, 2014 IP
  11. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #11
    What what?
     
    nico_swd, Jun 13, 2014 IP