Jump to content

Help with basic php


xxreenaxx1

Recommended Posts

So I was working on these two files shown below, I couldnt figure the problem.

 

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>

  <head>

    <title>New Customer Registration Form</title>

    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

  </head>

 

  <body>

      <form action="ma801rr_process.php" method="post">

          <p>Title<select name="title">

<option value="Mr">Mr</option>

<option value="Mrs">Mrs</option>

<option value="Ms">Ms</option>

        <option value="Dr">Dr</option>

<option value="Prof">Prof</option>

</select>

 

          <p>First name:</p>

          <p><input name="forename" type="text" size="20" /></p>

          <p>Family name:</p>

          <p><input name="surname" type="text" size="20" /></p>

          <p>Address:</p>

          <p><input name="adress" cols="20" rows="4"></input></p>

 

          <p><input type="submit" value="Click"

          name="submit" /></p>

 

          <input type="hidden" name="submitted" value="true" />

  </form>

  </body>

</html>

 

 

 

 

 

<?php

// handle_reg_form.php

 

if (isset($_POST['submitted'])) {

 

 

        setcookie('title',$title);

setcookie('forename',$forename);

        setcookie('surname',$surname);

setcookie('address',$address);

 

        $title = $_POST['title'];

$forename = $_POST['forename'];

$surname = $_POST['surname'];

        $address = $_POST['address'];

 

 

 

 

}

 

print '<html>

    <head>

        <meta http-equiv="Content-Type"

              content="text/html; charset=UTF-8">

        <title>Hello New Customer</title>

    </head>

    <body>';

 

 

        print '<p>Hello $title $forename $surname  of $address</p>'

 

//print    '</body></html>'

 

 

?>

Link to comment
https://forums.phpfreaks.com/topic/192624-help-with-basic-php/
Share on other sites

well. it should start with displaying title, firstname, surname and address..

 

When someone enters their details it should take them to the second "Quote"... the details(which entered) should be saved in cookies and it should be displayed on the same page. "print '<p>Hello $title $forename $surname  of $address</p>'

"

Link to comment
https://forums.phpfreaks.com/topic/192624-help-with-basic-php/#findComment-1014798
Share on other sites

You can't send cookie to browser if you already started sending html data. Setcookie function must be invoked first , there must be nothing, not even empty space before <?php sign . Other php code inside <?php ?> is ok, but you mustn't echo anything before setcookie. Some character sets put some bytes on beginning of a file, so you have to set your file to UTF8 NO BOM.

 

Goat

Link to comment
https://forums.phpfreaks.com/topic/192624-help-with-basic-php/#findComment-1014994
Share on other sites

Thank you "Goat" and other people who helped me. Now that everything is working finr. my address wont show. I have tried to check if the name is correct. But still nothing..

 

<p>Address:</p>
          <p><input name="adress" cols="20" row="4"></input></p>

 

$address = $_POST['address'];

 

print "<p>Hello $title $forename $surname  of $adress </p>"

Link to comment
https://forums.phpfreaks.com/topic/192624-help-with-basic-php/#findComment-1015010
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.