/    Sign up×
Community /Pin to ProfileBookmark

Why won’t it work!?

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

[code=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>
[/code]

to post a comment
PHP

7 Comments(s)

Copy linkTweet thisAlerts:
@phpnoviceJan 21.2005 — Would need to see the content of the register2.php document.
Copy linkTweet thisAlerts:
@NogDogJan 21.2005 — [i]Originally posted by phpnovice [/i]

[B]Would need to see the content of the register2.php document. [/B][/QUOTE]

Yeah, my best guess is that it's register2.php which is doing a redirect to the login page.
Copy linkTweet thisAlerts:
@alliekins619authorJan 21.2005 — Here's register2.php

[code=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>
[/code]
Copy linkTweet thisAlerts:
@NogDogJan 21.2005 — Got me stumped, unless it's something in one of the require()'ed files, which does not seem too likely.
Copy linkTweet thisAlerts:
@phpnoviceJan 21.2005 — Show me a document that references [b]login.php[/b] and I'll show you the problem.
Copy linkTweet thisAlerts:
@alliekins619authorJan 21.2005 — *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.
Copy linkTweet thisAlerts:
@phpnoviceJan 21.2005 — As long as it is resolved, that is all that matters. ?
×

Success!

Help @alliekins619 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.6,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...