xxreenaxx1 Posted February 19, 2010 Share Posted February 19, 2010 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 More sharing options...
Wolphie Posted February 19, 2010 Share Posted February 19, 2010 Well first, what are you trying to achieve? Link to comment https://forums.phpfreaks.com/topic/192624-help-with-basic-php/#findComment-1014781 Share on other sites More sharing options...
xxreenaxx1 Posted February 19, 2010 Author Share Posted February 19, 2010 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 More sharing options...
teamatomic Posted February 19, 2010 Share Posted February 19, 2010 When extrapolating vars you need to use double quotes. print "<p>Hello $title $forename $surname of $address</p>"; HTH Teamtomic Link to comment https://forums.phpfreaks.com/topic/192624-help-with-basic-php/#findComment-1014818 Share on other sites More sharing options...
xxreenaxx1 Posted February 19, 2010 Author Share Posted February 19, 2010 Yeh you are right it worked, but its telling me that.. my cannot modify header information - header already send by setcookie('title',$title); setcookie('forename',$forename); setcookie('surname',$surname); setcookie('address',$address); Link to comment https://forums.phpfreaks.com/topic/192624-help-with-basic-php/#findComment-1014853 Share on other sites More sharing options...
Goat Posted February 19, 2010 Share Posted February 19, 2010 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 More sharing options...
xxreenaxx1 Posted February 19, 2010 Author Share Posted February 19, 2010 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 More sharing options...
teamatomic Posted February 19, 2010 Share Posted February 19, 2010 <p>Address:</p> <p><input name="adress" cols="20" row="4"></input></p> HTH Teamatomic Link to comment https://forums.phpfreaks.com/topic/192624-help-with-basic-php/#findComment-1015011 Share on other sites More sharing options...
xxreenaxx1 Posted February 19, 2010 Author Share Posted February 19, 2010 OOPS.. just figured it.. Thank you.. Link to comment https://forums.phpfreaks.com/topic/192624-help-with-basic-php/#findComment-1015017 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.