- Joined
- Oct 17, 2012
- Messages
- 49
- Reaction score
- 3
Hey guys. i been messing with these codes for a good hour and i got pretty much everything working but i cant get it to where when a user presses submit it checks that the fields are all filled and checks if the username he/she chose is being used or not and if the email he/she is using is being used.
Register.php
PHP:
<form id="registration" name="registration" method="post" action="regcheck.php">
<table border="0" id="form_table">
<caption>Register</caption>
<tr>
<th width="25%">Username ›</th>
<td>
<input type="text" id="username" name="name">
<span>Enter Your Username</span>
</td>
</tr>
<tr>
<th>Email ›</th>
<td>
<input type="text" id="email" name="email">
<span>Your Active Email Address</span>
</td>
</tr>
<tr>
<th>Password ›</th>
<td>
<input type="password" id="pass1" name="pass1">
<span>More than 8 Characters long</span>
</td>
</tr>
<tr>
<th>Retype Password ›</th>
<td>
<input type="password" id="pass2" name="pass2">
<span>More than 8 Characters Long</span>
</td>
</tr>
<tr>
<th> </th>
<td>
<input type="submit" name="submit" value="Register!">
<input type="button" name="button" value="Cancel" onclick='window.location="index.php"'/>
</td>
</tr>
</table>
</form>
File that adds users into the database
(i just call it regcheck.php in my files)
(i just call it regcheck.php in my files)
PHP:
<html>
<head>
<link rel="stylesheet" type="text/css" href="global.css">
<?php include("inc/header.inc");?>
<?php include("inc/footer.inc");?>
</head>
<body>
<?php
$host="localhost";
$username="fate";
$password="";
$db_name="test";
$tbl_name="members";
if($_POST["name"] && $_POST["email"] && $_POST["pass1"] && $_POST["pass2"] )
if($_POST["pass1"]==$_POST["pass2"])
mysql_connect("$host","$username","$password")or die(mysql_error());
mysql_select_db("$db_name");
$sql="insert into members (username,email,password)values('$_POST[name]','$_POST[email]','$_POST[pass1]')";
$result=mysql_query($sql) or die(mysql_error());
print "<h1>you have registered sucessfully</h1>";
print "<a href='index.php'>go to login page</a>";
?>
</body>
</html>

