Hi
I have altered a few things in my script that sends info to another page. Basically, I can see the info I have sent in the URL of the target page, it looks like this:
/~p0c79/teacher.php?UserName=David+Graham&logondetails=1+password
And now all the page is asked to do is print the UserName like this:
print("Greetings " . $UserName . "<br>\n");
However, all I get is 'Greetings' , nothing else. Is it because I have also passed other info called logondetails?
I have enclosed the scripts, here is the form script:
<HTML>
<HEAD>
<TITLE> Sample Page </TITLE>
</HEAD>
<BODY>
</body>PHP Code:<?php
if ($Message == "Invalid") {
print ("<B><CENTER><FONT COLOR=RED>The id and password you entered do not match what is on file. Please try again!</FONT></CENTER></B>\n");
}
if (isset($firstname) AND isset($surname) AND isset($password) AND isset($userid))
{
$name=$firstname . " " . $surname;
$logondetails=$userid . " " . $password;
// Now we will welcome the user to our site.
print("<P><b><center>Wellcome: $name </center></b><br> This is the feedback part of the \'Humans As Organisms\' module.<P>\n");
$name=urlencode($name);
$logondetails=urlencode($logondetails);
print("<P>Click here <A HREF= \"bestpassword5.php?name=$name&logondetails=$logondetails\">link</A>\n");
print(" to be taken to a page that will display your test results.</P>\n");
}
else
{
print(" <!-- No name has been provided, so we
prompt the user for one. -->");
print(" <FORM ACTION = $PHP_SELF METHOD = POST><br>\n");
print(" Please enter your first name: <INPUT TYPE = TEXT NAME = \"firstname\"><br>\n");
print(" Please enter your surname: <INPUT TYPE = TEXT NAME = \"surname\"><br>\n");
print(" Please enter your userid: <INPUT TYPE = TEXT NAME = \"userid\"><br>\n");
print(" Please enter your password: <INPUT TYPE = PASSWORD NAME = \"password\"><br>\n");
print(" <INPUT TYPE = SUBMIT VALUE = \"GO\">\n");
print(" </FORM><br>\n");
}
?>
</html>
Here is the script that handles output from the script:
<html>
<Head>
<title>Sample Page</title>
</Head>
<body>
<\body>PHP Code:<?php
$Host = "**********";// Set the variables for the database access:
$User = "******";
$MasterPassword = "******";
$DBName = "*****";
$TableName = "personaldetails";
$link = @mysql_connect("$Host", "$User", "$MasterPassword");
if (!$link)
{
print("<P>Unable to connect to the " .
"database server at this time.</P>\n");
exit();
}
if (! @mysql_select_db($DBName) )
{
print("<P>Unable to locate the $DBName database at this time.</P>\n");
exit();
}
$Array=explode(" ",$logondetails);
$Query="SELECT * FROM $TableName WHERE password='$Array[1]' AND userid='$Array[0]'";
$Result=mysql_query ($Query) or die(mysql_error());
$num_rows=mysql_num_rows($Result);
$Row = mysql_fetch_array ($Result);
if($num_rows==1)
{
if($Row['teacherstatus']=='Y')
{
$Newstring=implode(" ",$Array);
$logondetails=urlencode($Newstring);
$name=urlencode($name);
header("Location: teacher.php?UserName=$name&logondetails=$logondetails");
exit();
}
else
{
$Newstring=implode(" ",$Array);
$logondetails=urlencode($Newstring);
$name=urlencode($name);
header ("Location: student.php?UserName=$name&logondetails=$logondetails");
exit();
}
}
header ("Location: firstpage5.php?Message=Invalid");
exit();
mysql_close ($link);
?>
<\html>
Here is the teacher.php script:
<html>
<head>
<title>The teacher page</title>
</head>
<body>
[php]
<?php
$Array=explode(" ", $name);
$UserName=$Array[0] . " " . $Array[1];
print("Greetings " . $UserName . "<br>\n");
?>
[php]
</body>
</html>
Is it something simple?





Bookmarks