How to return html form values on the same page

Discussion in 'PHP' started by dondor, May 30, 2010.

  1. #1
    Hi all,

    I have a html based website with several elements in php.
    I need to return a few values from a html form on the same page, for example:

    This are the fields the user needs to fill:
    First Name
    Last Name
    Phone
    Email

    I need to return them like this and the first & last name I need to combine in to one variable (fullname):

    <div> hello %fullname%, your phone is: %phone% and your email is %email%</div>
    Code (markup):
    I can use php inside the page.

    Appreciate your help...
     
    dondor, May 30, 2010 IP
  2. abstractworld

    abstractworld Peon

    Messages:
    35
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    in form leave action attrib empty. It will send all the values of form to the same page...
    Now on top you can use php to get the posted values.e.g
    if you set method to POST in form you can use $email = $_POST['email']
    if you used GET you can use $_GET['email'];

    you can also use $_REQUEST['email'] to get values sent via any method
     
    abstractworld, May 30, 2010 IP
  3. actress143

    actress143 Peon

    Messages:
    132
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    i think he is saying that it's the html file..., so that might not work..,

    What do you say guys......, because abstractworld is correct in case if the form file is php.., but, as his conversation that is html,

    That might work if you can run php in html,

    ----- this is just what i am thinking...
     
    actress143, May 31, 2010 IP
  4. Bogdan2901

    Bogdan2901 Peon

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Yes, you can. You should use isset(); . Something like that:

    Or, you can store teh dates in COOKIES
     
    Bogdan2901, May 31, 2010 IP
  5. actress143

    actress143 Peon

    Messages:
    132
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    isset(); will works, but your file extension should be .php not .html
     
    actress143, Jun 1, 2010 IP