mr_badger Posted June 4, 2007 Share Posted June 4, 2007 I have a registration form and it works fine on localhost, I have now uploaded it to my server, but now when I fill in the form and click submit nothing happens, the form is blank again. This is the code: <?php //This function will display the registration form function register_form(){ $date = date('D, M, Y'); echo "<form action='?act=register' method='post'>" ."Username: <input type='text' name='username' size='30'><br><br />" ."Password: <input type='password' name='password' size='30'><br><br />" ."Confirm your password: <input type='password' name='password_conf' size='30'><br><br />" ."Email: <input type='text' name='email' size='30'><br><br />" ."<input type='hidden' name='date' value='$date'><br />" ."<input type='submit' value='Register'><br />" ."</form>"; } //This function will register users data function register(){ // Connects to your Database mysql_select_db($database_conn, $conn); $Result1 = mysql_query($insertSQL, $conn) or die(mysql_error()); //Collecting info $username = $_REQUEST['username']; $password = $_REQUEST['password']; $pass_conf = $_REQUEST['password_conf']; $email = $_REQUEST['email']; $date = $_REQUEST['date']; //Here we will check do we have all inputs filled if(empty($username)){ die("Please enter your username!<br>"); } if(empty($password)){ die("Please enter your password!<br>"); } if(empty($pass_conf)){ die("Please confirm your password!<br>"); } if(empty($email)){ die("Please enter your email!"); } //Let's check if this username is already in use $user_check = mysql_query("SELECT username FROM users WHERE username='$username'"); $do_user_check = mysql_num_rows($user_check); //Now if email is already in use $email_check = mysql_query("SELECT email FROM users WHERE email='$email'"); $do_email_check = mysql_num_rows($email_check); //Now display errors if($do_user_check > 0){ die("Username is already in use!<br>"); } if($do_email_check > 0){ die("Email is already in use!"); } //Now let's check does passwords match if($password != $pass_conf){ die("Passwords don't match!"); } //If everything is okay let's register this user $insert = mysql_query("INSERT INTO users (username, password, email) VALUES ('$username', '$password', '$email')"); if(!$insert){ die("There's little problem: ".mysql_error()); } echo $username.", you are now registered. Thank you!<br><a href=?act=login>Login</a> | <a href=index.php>Index</a>"; } switch($act){ default; register_form(); break; case "register"; register(); break; } ?> </div> Quote Link to comment https://forums.phpfreaks.com/topic/54135-probably-a-simple-registration-question/ Share on other sites More sharing options...
sasa Posted June 4, 2007 Share Posted June 4, 2007 add line $act = $_GET['act']; before switch stateman Quote Link to comment https://forums.phpfreaks.com/topic/54135-probably-a-simple-registration-question/#findComment-267625 Share on other sites More sharing options...
trq Posted June 4, 2007 Share Posted June 4, 2007 add line $act = $_GET['act']; before switch stateman And turn register_globals off on your test server. They have long been depricated and you should code accordingly. They are a major security issue. Quote Link to comment https://forums.phpfreaks.com/topic/54135-probably-a-simple-registration-question/#findComment-267626 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.