xxreenaxx1 Posted February 23, 2010 Share Posted February 23, 2010 So I have created three files.. First one to ask the user to enter the details.. The second one to display these details, with the cookies.. n if any of the detail is not typed.. then an error message is shown.. Welcome page.. this shows the details from second file and display it here.. even when the browser is closed, it will still should display it.. but thats not happening my first page <!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="get"> <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="address" cols="20" row="4"></input></p <p><input type="submit" value="Click" name="submit" /></p> <input type="hidden" name="submitted" value="true" /> </form> </body> </html> My second page <?php $done=TRUE; $title = $_GET['title']; $forename = $_GET['forename']; $surname = $_GET['surname']; $address = $_GET['address']; if(empty($_GET['forename'])){ print '<p class="error">Please enter your forename.</p>'; $done = FALSE;} if(empty($_GET['surname'])){ print '<p class="error">Please enter your surname.</p>'; $done = FALSE;} if(empty($_GET['address'])){ print '<p class="error">Please enter your address.</p>'; $done = FALSE;} setcookie('title',$title,time()+3600); setcookie('forename',$forename,time()+3600); setcookie('surname',$surname,time()+3600); setcookie('address',$address,time()+3600); print '<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Hello New Customer</title> </head> <body>'; if($done){ print "<p>Hello $title $forename $surname of $address </p>";} print '</body></html>'; ?> Welcome page <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Handle Form 1</title> </head> <body> <?php if (isset($_POST['submitted'])) { // Send the cookies: setcookie('forename', $_POST['forename'], time()+3600); setcookie('surname', $_POST['surname'], time()+3600); setcookie('address', $_POST['address'], time()+3600); setcookie('title', $_POST['title'], time()+3600); // Message to be printed later: //$msg = '<p>Your Inputs have been entered so it all in the history ! Click <a href="handle_form2.php">here</a> to see them in action.</p>'; } if (isset($msg)) { print $msg; } $title = $_COOKIE['title']; $forename = $_COOKIE['forename']; $surname = $_COOKIE['surname']; $address = $_COOKIE['address']; print '<p>Welcome Back ' . "$title $forename $surname" . ' of ' . "$address</p>"; ?> </body> </html> Link to comment https://forums.phpfreaks.com/topic/193132-stuck-with-php-welcome-page-is-not-diaplyed/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.