PDA

View Full Version : Error


Necrosis
01-21-2006, 03:53 PM
Well i use this script and i name it register.php. But when i open it it shows nothing.
necrosis.orgfree.com/register.php

<?php

if (isset($_POST['submit'])) {
// Register User
if($connection = mysql_connect(localhost, "YOURUSER", "YOURPASS")) {
mysql_select_db("member_system") or die(mysql_error());
} else {
die("Failed to connect to MySQL:<br>\n".mysql_error());
}

$nickname = $_POST['nickname'];
$email = $_POST['email'];
$password = $_POST['pass'];
$password_again = $_POST['pass_again'];
$pokemon = $_POST['pokemon'];

if(!(isset($nickname))) {
die("<p align=\"center\" style=\"color:red;\">You did not enter a nickname, go back and enter a nickname.</p>");
}
if(!(isset($email))) {
die("<p align=\"center\" style=\"color:red;\">You did not enter a email address, go back and enter a email address.</p>");
}
if($password !== $password_again) {
die("<p align=\"center\" style=\"color:red;\">Your passwords did not match, go back and be sure to enter in your password again correctly.</p>");
}

$query = "INSERT * INTO members VALUES('', '".$nickname."', '".$email."', '".$password."', '".$pokemon."')";
if(true == ($result = mysql_query($query))) {
echo "<p align=\"center\" style=\"color:green;\">Congratulations! You have successfully regisered with the fallowing information:</p>";
echo "<p align="center">";
foreach ($_POST as $key => $val) {
echo "<b>".$key.":</b> ".$val."<br />\n";
}
echo "</p>";
echo "<p align=\"center\">To login please go <a href=\"login.php\">here.</a></p>";
}

@mysql_close($connection);

} else {

// Sign Up Form
?>
<p align="center" style="font-family:tahoma;font-size:12px;font-wheight:bold;">Sign Up</p>
<form name="signup" method="post" action="<?php echo $_SERVER['REQUEST_URI']; ?>">
<p align="center"><b>Nickname:</b> <input type="text" size="21" name="nickname" value="Ash"></p>
<p align="center"><b>Email:</b> <input type="text" size="21" name="nickname"></p>
<p align="center"><b>Password:</b> <input type="password" size="21" name="pass"><br>
<b>Password Again:</b> <input type="password" size="21" name="pass_again"></p>
<p align="center"><b>Starting Pokčmon:</b>
<select name="pokemon">
<option value="Bulbasour"> Bulbasour
<option value="Charmander"> Charmandr
<option value="Squirtle"> Squirtle
</select>
<p align="center"><input type="submit" name="submit" value="Sign Up!"></p>
</form>
<?php

}

?>

arne
01-21-2006, 06:20 PM
Hi, try this:
<?php

if (isset($_POST['submit'])) {
// Register User
if($connection = mysql_connect(localhost, "YOURUSER", "YOURPASS")) {
mysql_select_db("member_system") or die(mysql_error());
} else {
die("Failed to connect to MySQL:<br>\n".mysql_error());
}

$nickname = $_POST['nickname'];
$email = $_POST['email'];
$password = $_POST['pass'];
$password_again = $_POST['pass_again'];
$pokemon = $_POST['pokemon'];

if(!(isset($nickname))) {
die("<p align=\"center\" style=\"color:red;\">You did not enter a nickname, go back and enter a nickname.</p>");
}
if(!(isset($email))) {
die("<p align=\"center\" style=\"color:red;\">You did not enter a email address, go back and enter a email address.</p>");
}
if($password !== $password_again) {
die("<p align=\"center\" style=\"color:red;\">Your passwords did not match, go back and be sure to enter in your password again correctly.</p>");
}

$query = "INSERT * INTO members VALUES('', '".$nickname."', '".$email."', '".$password."', '".$pokemon."')";
if(true == ($result = mysql_query($query))) {
echo "<p align=\"center\" style=\"color:green;\">Congratulations! You have successfully regisered with the fallowing information:</p>";
echo "<p align=\"center\">";
foreach ($_POST as $key => $val) {
echo "<b>".$key.":</b> ".$val."<br />\n";
}
echo "</p>";
echo "<p align=\"center\">To login please go <a href=\"login.php\">here.</a></p>";
}

@mysql_close($connection);

} else {

// Sign Up Form
?>
<p align="center" style="font-family:tahoma;font-size:12px;font-wheight:bold;">Sign Up</p>
<form name="signup" method="post" action="<?php echo $_SERVER['REQUEST_URI']; ?>">
<p align="center"><b>Nickname:</b> <input type="text" size="21" name="nickname" value="Ash"></p>
<p align="center"><b>Email:</b> <input type="text" size="21" name="nickname"></p>
<p align="center"><b>Password:</b> <input type="password" size="21" name="pass"><br>
<b>Password Again:</b> <input type="password" size="21" name="pass_again"></p>
<p align="center"><b>Starting Pokčmon:</b>
<select name="pokemon">
<option value="Bulbasour"> Bulbasour
<option value="Charmander"> Charmandr
<option value="Squirtle"> Squirtle
</select>
<p align="center"><input type="submit" name="submit" value="Sign Up!"></p>
</form>
<?php

}

?>


You forgot on (i think it was line 30) to put \"center\"> instead of "center", so you just forgot \ (at least that's what i think )

Necrosis
01-21-2006, 06:49 PM
ok, it registers me. But it says:
Enter the required information to join PokęHaven!

;s

Necrosis
01-21-2006, 06:52 PM
site:
http://necrosis.orgfree.com

Necrosis
01-22-2006, 04:53 AM
ok... it works fine but it doesnt register =/