Forum Moderators: coopster
I was wondering if it was possible to display a name from a form that was enailed.
I have a form on one page that gets sent to an email then redirects the user to another page after the email was successfully sent.
I want to be able to put the name of the user that just submitted the data on the success page.
Many Thanks all
then on the landing page
$username=$_POST['username'];
// security stuffs allowing only for alpha characters
if(!preg_match("/^[AZaz]*$/", $username))
{
echo"<h3>the user name etc....</h3>
<a href='address back to the form'>Please, supply a correct username</a>";
}
Next using a session
top of both pages add
session_start();
First page, you should have a value for the username
say it's $username
then add
$_SESSION['username']=$username;
$username=$_SESSION['username'];
On the landing page
add
$username=$_SESSION['username'];
if(!preg_match("/^[AZaz]*$/", $username))
{
echo"<h3>the user name etc....</h3>
<a href='address back to the form'>Please, supply a correct username</a>";
}
if(!preg_match("/^[AZaz]*$/", $username))
so a blank or null string would match on this, a safer bet is one or more
if(!preg_match("/^[A-Za-z]+$/", $username))
or just case-insensitive
if(!preg_match("/^[A-Z]+$/i", $username))
I have a form on one page that gets sent to an email then redirects the user to another page after the email was successfully sent....I want to be able to put the name of the user that just submitted the data on the success page.
Use henry0's method, OR you could use a query string and Location header:
$email=$_POST['email'];
$u=$_POST['username'];
header("Location:http://example.com/second-page.php?email=$email&u=$u");
if (!ctype_alpha($username)) {
//do something here
}
I'll give it all a go and see which one is better.
Many Thanks all