Click to See Complete Forum and Search --> : Why won't it work!?


alliekins619
01-20-2005, 09:49 PM
register.php is SUPPOSED to collect the form data and ship it off to register2.php, where it is inserted into the database and all that good stuff. But, for some reason, it keeps redirecting pages to login.php. WHY!?!?

register.php

<?php
session_start();
header("Cache-control: private");
?>
<HTML>
<HEAD>
<link rel="stylesheet" type="text/css" href="bluestyle.css">
</HEAD>
<BODY>
<?php
require("layout.php");
?>
<DIV CLASS="main">
<script language="javascript">
function check()
{
if (reg.name.value == "" || reg.pass1.value == "" || reg.pass2.value == "") {
alert("One or more required fields is blank. Please fix this and try again.");
return false;
}
else if (reg.pass1.value != reg.pass2.value) {
alert("Your passwords do not match.");
return false;
}
else {
return true;
}
}
</script>
<CENTER><FORM name="reg" ACTION="register2.php" METHOD="POST" onSubmit="return check();">
Please enter the following information to register with the database. You can later add characters to your profile.<P>
<B>All fields are cAsE sEnSiTiVe!!</B><P>
<TABLE>

<TR><TD align="right">*Name/Alias: </TD><TD><input type="text" name="name" maxlength="15"></TR>
<TR><TD align="right">*Password: </TD><TD><input type="password" name="pass1" maxlength="15"><TR>
<TR><TD align="right">*Confirm password: </TD><TD><input type="password" name="pass2" maxlength="15"><TR>
<TR><TD align="right">MSN: </TD><TD><input type="text" name="msn"><TR>
<TR><TD align="right">AIM: </TD><TD><input type="text" name="aim"><TR>
<TR><TD align="right">Email address: </TD><TD><input type="text" name="email"><TR>
<TR><TD></TD><TD><input type="submit" value="Register me!">
<BR>
* indicates required fields
</DIV>
</BODY>
</HTML>

phpnovice
01-20-2005, 11:03 PM
Would need to see the content of the register2.php document.

NogDog
01-21-2005, 09:26 AM
Originally posted by phpnovice
Would need to see the content of the register2.php document.
Yeah, my best guess is that it's register2.php which is doing a redirect to the login page.

alliekins619
01-21-2005, 12:02 PM
Here's register2.php


<?php
session_start();
header("Cache-control: private");
?>
<HTML>
<HEAD>
<link rel="stylesheet" type="text/css" href="bluestyle.css">
</HEAD>
<BODY>
<?php
require("layout.php");
require("db_connect.php");
echo "<DIV CLASS='main'>";

$name=$_POST['name'];
$pass=$_POST['pass1'];
$msn=$_POST['msn'];
$aim=$_POST['aim'];
$email=$_POST['email'];
$joined=date("M d y h:i T");

$active="N/A";

$query="INSERT INTO users VALUES('','$name','$pass','$msn','$aim','$email','$joined','$active','0')";
mysql_query($query);
$error=mysql_error();
echo mysql_error();
mysql_close();
if ($error=="")
echo "Congratulations! It appears your registration was a success. <a href='testdisp.php'>Click here</a> to make sure you're on the list of users.";
else
echo "We're sorry, there was some sort of error. <BR>" . $error;

?>
</DIV>
</BODY>
</HTML>

NogDog
01-21-2005, 12:33 PM
Got me stumped, unless it's something in one of the require()'ed files, which does not seem too likely.

phpnovice
01-21-2005, 12:53 PM
Show me a document that references login.php and I'll show you the problem.

alliekins619
01-21-2005, 02:35 PM
*sighs* I just found the problem.

In the sidebar (sidebar.php) there is a login form, which then takes you to login.php. And I never closed the form tag.

I never thought to look in there until I brought up the acutal php-generated source of the page.

Anyway, thanks for your attempts to correct my stupidity.

phpnovice
01-21-2005, 03:06 PM
As long as it is resolved, that is all that matters. :D