fife Posted July 28, 2010 Share Posted July 28, 2010 Hi, I'm very new to php. just wrote my first insert script which works great. Now when my script has run it sends you to the thank you page. It also sends username through a post. Now I'm trying to display Dear <? username ?> But i cant get it working. can anyone help? Here is the code for the join page <?php include('database name'); session_start(); $validation_id = strval(time()); if(isset($_POST['submit'])) { $first_name = mysql_real_escape_string($_POST['first_name']); $last_name = mysql_real_escape_string($_POST['last_name']); $DOB = mysql_real_escape_string($_POST['DOB']); $sex = mysql_real_escape_string($_POST['sex']); $email = mysql_real_escape_string($_POST['email']); $username = mysql_real_escape_string($_POST['username']); $password = mysql_real_escape_string($_POST['password']); $agree = mysql_real_escape_string($_POST['agreed']); $creation_date = mysql_real_escape_string($_POST['creation_date']); $user_type = mysql_real_escape_string($_POST['member_type']); $access_level = mysql_real_escape_string($_POST['access_level']); $validation = mysql_real_escape_string($_POST['validation_id']); $club_user = mysql_real_escape_string($_POST['user_type']); $insert_member= "INSERT INTO Members (`first_name`,`last_name`,`DOB`,`sex`,`email`,`username`,`password`,`agree`,`creation_date`,`usertype`,`access_level`,`validationID`) VALUES ('".$first_name."','".$last_name."','".$DOB."','".$sex."','".$email."','".$username."','".$password."','".$agree."','".$creation_date."','".$user_type."','".$access_level."', '".$validation."')"; $insert_member_now= mysql_query($insert_member) or die(mysql_error()); $url = "thankyou.php?name=".$_POST[$username]; header('Location: '.$url); } Also the form looks like this <form method="POST" name="member_accounts" id="member_accounts"> <input name="username" type="text" class="form_fields" value="<?php echo $_POST['username'];?>" size="20" /> <input name="password" type="password" class="form_fields" value="<?php echo $_POST['password'];?>" size="21" /> now here is the code on the thank you next page. <? include('database name'); session_start(); $_POST['username']= $username; ?> <body> <div id="wrapper"> <h3 class="para_space">Dear <?php echo $_REQUEST[$username]; ?></h3> Quote Link to comment https://forums.phpfreaks.com/topic/209099-displaying-fields-from-url/ Share on other sites More sharing options...
Alex Posted July 28, 2010 Share Posted July 28, 2010 <h3 class="para_space">Dear <?php echo $_GET['name']; ?></h3> Quote Link to comment https://forums.phpfreaks.com/topic/209099-displaying-fields-from-url/#findComment-1092064 Share on other sites More sharing options...
fife Posted July 28, 2010 Author Share Posted July 28, 2010 hello. Right I changed the code to reflect the reply to my message. The form works great and inserts the data yet even with the get command on my thank you page it still does not display a name Quote Link to comment https://forums.phpfreaks.com/topic/209099-displaying-fields-from-url/#findComment-1092071 Share on other sites More sharing options...
Alex Posted July 28, 2010 Share Posted July 28, 2010 That's because the URL you're redirecting to does not contain the username. This is wrong: $url = "thankyou.php?name=".$_POST[$username]; $_POST[$username] does not exist; instead it should be $_POST['username']. $url = "thankyou.php?name=".$_POST['username']; And then on the other page it should still remain: <h3 class="para_space">Dear <?php echo $_GET['name']; ?></h3> Quote Link to comment https://forums.phpfreaks.com/topic/209099-displaying-fields-from-url/#findComment-1092083 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.