Here is my code. I am trying to create a user login and registration. The problem is that nothing happens. Here is my code.
<?php
function register() {
include "connect.php";
$con = mysql_connect($host, $uname, $pass) or die(mysql_error());
mysql_select_db($dbname, $con) or die(mysql_error());
$username= trim($_POST['username']);
$password = trim($_POST['password']);
$pass_conf= trim($_POST['pass_conf']);
$email = trim($_POST['email']);
//Check the Data
if(empty($username)) {
die ("Fill in a username!");
}
if(empty($password)) {
die ("You forgot to fill in a password!");
}
if(empty($pass_conf)) {
die ("Confirm your password");
}
if(empty($email)) {
die ("We can't register you without an email");
}
$patt = "^[A-Za-z1-9 _-]+$";
if(!ereg($patt,$username)) {
die("Invalid characters in your username");
}
if(!ereg($patt,$password)) {
die("Invalid characters in your password");
}
if(!ereg("^.+@.+$", $email)) {
die ("Invalid email format.");
}
if ($password != $pass_conf) {
die ("The two passwords do not match!");
}
//Check to see if username is in use already.
$sql=mysql_query("SELECT username from users WHERE username = '$username'") or die(mysql_error
());
$num_rows = mysql_num_rows($sql);
if($num_rows > 0) {
die ("Username already exists!");
}
//Check to see if email is in use or not.
$sql2=mysql_query("SELECT email from users WHERE email = '$email'") or die(mysql_error());
$num_rows2 = mysql_num_rows($sql2) or die(mysql_error());
if($num_rows2 > 0) {
die ("E-mail is in use!");
}
echo "test";
}
function register_form() {
echo "<center><img src='My Pictures/Waffle Banner.jpg'>
<form action='?act=register' method='POST'>
<b>Please register below</b>
<table align='center' border='0'>
<tr><td>Username</td><td><input type='text' name='username'>
</td>
</tr>
<tr><td>
Password:</td><td><input type='password' name='password'>
</td>
</tr>
<tr><td>Confirm your password:</td>
<td><input type='password' name='pass_conf'></td>
</tr>
<tr>
<td>
E-mail:
</td>
<td>
<input type='text' name='email'>
</td>
</tr>
<tr><td></td><td>
<input type='submit' value='Register'></td></tr>
</table>
</form>
</center>";
}
$act = $_GET['act'];
switch($act){
case register:
register();
break;
default:
register_form();
}
?>
What is supposed to happen is for it to display test (Testing purposes) if the information is acceptable. Nothing happens however. Can anyone help me? Php5.2.1, Apache 2.0.59, mysql 5.0.