Jump to content

displaying fields from url


fife

Recommended Posts

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>  

Link to comment
https://forums.phpfreaks.com/topic/209099-displaying-fields-from-url/
Share on other sites

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>  

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.