...

View Full Version : need help with register



due
11-26-2006, 10:37 PM
when i insert details it refreshes why?
<html>
<head>
<title>War of chaos V2</title>
<link rel="stylesheet" type="text/css"
href="css/style.css" />
</head>
<body>
<table border="0">
<tr>

<td>
<form action="login.php" method="post">
Username: <input name="username" id="username" value="usernamehere" type="text" maxlength="30" /><br />
Password: <input name="password" id="password" value="pass" type="password" /><br />
<input type="submit" value="Log In" /><br />
<a href="register.php">Register</a><br />
<a href="forgot.php">Forgot Pass?</a>
</form>
</td></tr></table>
<table border="0" width="100%">
<tr>
<th bgcolor="#690000"><center>REGISTER</th></tr></table>
<?
include "config.php";
if(!empty($_POST['lsubmit'])&& (empty($_POST['username'])||empty($_POST['password'])||empty($_POST['rpassword'])||empty($_POST['race'])||empty($_POST['email'])||empty($_POST['remail'])))
{
echo "Please Fill Out all fields";
}
elseif(!empty($_POST['lsubmit'])) {
$created = mysql_query("INSERT INTO users ('username','email','race','password') VALUES( '{$_POST['username']}', '{$_POST['email']}', '{$_POST['race']}', '{$_POST['password']}' )");

// error
$to = $_POST['email'];
$subject = 'Welcome to War of Chaos V2';
$message = "Welcome to War of chaos v2 Have fun<br> your login info is below<br>Login Info:<br> Username:{$_POST['username']}<br>Password:{$_POST['password']}";
$headers = 'From: admin@warofchaos.cjb.net' . "\r\n" .
'Reply-To: ericglazebrook@gmail.com' . "\r\n" .
'X-Mailer: PHP/' . phpversion();

mail($to, $subject, $message, $headers);
echo "MAIL SENT";
}
?>

<center><form action="">
<table border="0">
<tr>
<td>Username:</td><td><input name="username" type="text"></td></tr>
<tr><td>Password:</td><td><input name="password" type="password"></td></tr>
<tr><td>Re-Password:</td><td><input name="rpassword" type="password"></td></tr>
<tr><td>Race:</td><td><select id="race" name="race">
<option value="Gods">Gods</option><option value="Slaves">Slaves</option><option value="vampires">Vampires</option><option value="globlins">Globins</option></td></tr>
<tr><td>Email:</td><td><input name="email" type="text"></td></tr>
<tr><td>Re-Email:</td><td><input name="remail" type="text"></td></tr>
<tr><td>Register:</td><td><input name="lsubmit" type="submit" id="lsubmit" value="Register"></td></tr>
</table>
</form></center>
</div>
<br style="clear:both" />
<div id="footer" align="center">&copy; War of chaos</div>
</body>
</html>

Fumigator
11-27-2006, 08:01 AM
mre nfo

CFMaBiSmAd
11-27-2006, 08:27 AM
Your code unconditionally displays the form at the top and the form at the bottom. When you enter information in the bottom form and press the submit button, the target is this same page. This causes the form at the top to be sent to the browser again, the mail(...) code is executed, and the form at the bottom is sent to the browser again.

If you don't want this to occur, you must add conditional logic around the form code that prevents it from being executed when the form is submitted.

due
11-27-2006, 08:25 PM
so if i did an include would it work?

due
11-27-2006, 08:43 PM
<html>
<head>
<title>War of chaos V2</title>
<link rel="stylesheet" type="text/css"
href="css/style.css" />
</head>
<body>
<table border="0">
<tr>

<td>
<form action="login.php" method="post">
Username: <input name="username" id="username" value="usernamehere" type="text" maxlength="30" /><br />
Password: <input name="password" id="password" value="pass" type="password" /><br />
<input type="submit" value="Log In" name="lsubmit" id="lsubmit" /><br />
<a href="register.php">Register</a><br />
<a href="forgot.php">Forgot Pass?</a>
</form>
</td></tr></table>
<table border="0" width="100%">
<tr>
<th bgcolor="#690000"><center>REGISTER</th></tr></table>
<?
include "config.php";
if(!empty($_POST['submit'])&& (empty($_POST['username'])||empty($_POST['password'])||empty($_POST['rpassword'])||empty($_POST['race'])||empty($_POST['email'])||empty($_POST['remail'])))
{
echo "Please Fill Out all fields";
}
elseif(!empty($_POST['submit'])) {
$created = mysql_query("INSERT INTO users ('username','email','race','password') VALUES( '{$_POST['username']}', '{$_POST['email']}', '{$_POST['race']}', '{$_POST['password']}' )");

// error
$to = $_POST['email'];
$subject = 'Welcome to War of Chaos V2';
$message = "Welcome to War of chaos v2 Have fun<br> your login info is below<br>Login Info:<br> Username:{$_POST['username']}<br>Password:{$_POST['password']}";
$headers = 'From: admin@warofchaos.cjb.net' . "\r\n" .
'Reply-To: ericglazebrook@gmail.com' . "\r\n" .
'X-Mailer: PHP/' . phpversion(5);

mail($to, $subject, $message, $headers);
echo "MAIL SENT";
}


echo "<center><form action=>
<table border=0>
<tr>
<td>Username:</td><td><input name=username type=text></td></tr>
<tr><td>Password:</td><td><input name=password type=password></td></tr>
<tr><td>Re-Password:</td><td><input name=rpassword type=password></td></tr>
<tr><td>Race:</td><td><select id=race name=race>
<option value=Gods>Gods</option><option value=Slaves>Slaves</option><option value=vampires>Vampires</option><option value=globlins>Globins</option></td></tr>
<tr><td>Email:</td><td><input name=email type=text></td></tr>
<tr><td>Re-Email:</td><td><input name=remail type=text></td></tr>
<tr><td>Register:</td><td><input name=submit type=submit id=submit value=Register></td></tr>
</table>
</form></center>";
?>
</div>
<br style="clear:both" />
<div id="footer" align="center">&copy; War of chaos</div>
</body>
</html>

due
11-27-2006, 08:51 PM
<html>
<head>
<title>War of chaos V2</title>
<link rel="stylesheet" type="text/css"
href="css/style.css" />
</head>
<body>
<table border="0">
<tr>

<td>
<form action="login.php" method="post">
Username: <input name="username" id="username" value="usernamehere" type="text" maxlength="30" /><br />
Password: <input name="password" id="password" value="pass" type="password" /><br />
<input type="submit" value="Log In" name="lsubmit" id="lsubmit" /><br />
<a href="register.php">Register</a><br />
<a href="forgot.php">Forgot Pass?</a>
</form>
</td></tr></table>
<table border="0" width="100%">
<tr>
<th bgcolor="#690000"><center>REGISTER</th></tr></table>
<?
include "config.php";
if(!empty(empty($_POST['username'])||empty($_POST['password'])||empty($_POST['rpassword'])||empty($_POST['race'])||empty($_POST['email'])||empty($_POST['remail'])))
{

echo "<center><form action=>
<table border=0>
<tr>
<td>Username:</td><td><input name=username type=text></td></tr>
<tr><td>Password:</td><td><input name=password type=password></td></tr>
<tr><td>Re-Password:</td><td><input name=rpassword type=password></td></tr>
<tr><td>Race:</td><td><select id=race name=race>
<option value=Gods>Gods</option><option value=Slaves>Slaves</option><option value=vampires>Vampires</option><option value=globlins>Globins</option></td></tr>
<tr><td>Email:</td><td><input name=email type=text></td></tr>
<tr><td>Re-Email:</td><td><input name=remail type=text></td></tr>
<tr><td>Register:</td><td><input name=submit type=submit id=submit value=Register></td></tr>
</table>
</form></center>";
}
if (!empty($_POST['submit'])) {
echo "Please Fill Out all fields";
}
elseif(!empty($_POST['submit'])) {
$created = mysql_query("INSERT INTO users ('username','email','race','password') VALUES( '{$_POST['username']}', '{$_POST['email']}', '{$_POST['race']}', '{$_POST['password']}' )");

// error
$to = $_POST['email'];
$subject = 'Welcome to War of Chaos V2';
$message = "Welcome to War of chaos v2 Have fun<br> your login info is below<br>Login Info:<br> Username:{$_POST['username']}<br>Password:{$_POST['password']}";
$headers = 'From: admin@warofchaos.cjb.net' . "\r\n" .
'Reply-To: ericglazebrook@gmail.com' . "\r\n" .
'X-Mailer: PHP/' . phpversion(5);

mail($to, $subject, $message, $headers);
echo "MAIL SENT";
}



?>
</div>
<br style="clear:both" />
<div id="footer" align="center">&copy; War of chaos</div>
</body>
</html>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum