Striapper Posted January 27 Share Posted January 27 (edited) Hi guys, i'm having trouble with my register page. I don't get any error but when I try to register i get a blank page and just cant figure out where i have gone wrong any help would be would be great Thanks in advance. <?php include "functions.php"; connect(); if(isset($_POST['register'])) { $username = protect($_POST['username']); $password = protect($_POST['password']); $email = protect($_POST['email']); if(strlen($username) > 20) { echo "Username must be less than 20 characters!"; }elseif(strlen($email) > 100) { echo "Email must be less than 100 characters!"; }else{ $stmt = $mysqli->prepare("SELECT username FROM user WHERE username = ? LIMIT 1"); $stmt->bind_param("s", $username); $stmt->execute(); $result = $stmt->get_result(); if($result->num_rows == 1) { echo "Username already taken!"; }else{ $sql = "INSERT INTO user (username, password, email) VALUES(?,?,?)"; $stmt = $db->prepare($sql); $stmt->bind_param("sss", $username, $password, $email); $stmt->execute(); echo "Sucsessfully registered"; $mysqli -> close(); } } } ?> Edited January 27 by Striapper Quote Link to comment https://forums.phpfreaks.com/topic/317657-my-register-page-doesnt-work/ Share on other sites More sharing options...
requinix Posted January 27 Share Posted January 27 If your script is working correctly then there will always be output - except in the case that there was no "register" submitted with the form. So first thing is to check that. Otherwise you'll have some sort of error. Make sure your php.ini is set up appropriately for a development environment by ensuring it has these two settings: display_errors = on error_reporting = -1 (like at the bottom) and then restart PHP/the server/whatever you're using. You should then end up with a not-blank page... Quote Link to comment https://forums.phpfreaks.com/topic/317657-my-register-page-doesnt-work/#findComment-1614446 Share on other sites More sharing options...
Andou Posted January 27 Share Posted January 27 What I do is add <?php ini_set('display_errors', '1'); ini_set('display_startup_errors', '1'); error_reporting(E_ALL); to the top of the file. This lets me see everything. It's the same thing as what requinix suggests, just doing it using code instead. Quote Link to comment https://forums.phpfreaks.com/topic/317657-my-register-page-doesnt-work/#findComment-1614467 Share on other sites More sharing options...
Barand Posted January 27 Share Posted January 27 Except that trying to execute ini_set('display_startup_errors', '1'); when the code doesn't run because of startup errors, is as much use as a chocolate teapot. It has to be set in the php.ini file. 2 Quote Link to comment https://forums.phpfreaks.com/topic/317657-my-register-page-doesnt-work/#findComment-1614471 Share on other sites More sharing options...
Andou Posted January 29 Share Posted January 29 On 1/27/2024 at 5:54 PM, Barand said: is as much use as a chocolate teapot Oops! I definitely have a lot more to learn. Great comparison, though. Quote Link to comment https://forums.phpfreaks.com/topic/317657-my-register-page-doesnt-work/#findComment-1614507 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.