coklat12 Posted September 16, 2007 Share Posted September 16, 2007 I have a problem with this code.. the mysql connection is working. there's nothing appear in the browser why?? <?php //Set the page title and include the HTML header $page_title = 'Register'; include ('./header.inc'); if (isset($_POST['submit'])) {// Handle the form. $message = NULL; // Create an empty new variable. //Check for a first name. if (empty($_POST['first_name'])){ $fn = FALSE; $message .= '<p>You forgot to enter your first name!</p>'; } else { $fn = $_POST['first_name']; } //Check for a last name. if(empty($_POST['last_name'])) { $ln = FALSE; $message .= '<p>You forgot to enter your last name!</p>'; } else { $ln = $_POST['last_name']; } //Check for an email address. if(empty($_POST['email'])) { $e = FALSE; $message .= '<p>You forgot to enter your email address!</p>'; } else { $e = $_POST['email']; } //Check for an username. if(empty($_POST['username'])) { $u = FALSE; $message .= '<p>You forgot to enter your username!</p>'; } else { $u = $_POST['username']; } //Check for the password and match against the confirmed password. if (empty($_POST['password1'])) { $p = FALSE; $message .= '<p>You forgot to enter your password!</p>'; } else { if ($_POST['password1'] == $_POST['password2']} { $p = $_POST['password1']; } else { $p = FALSE; $message .='<p>Your password did not match the confirmed password!</p>'; } } if ($fn && $ln && $e && $u && $p) {//if everything's ok. //Register the user in the database. require_once ('./mysql_connect.php'); //Connect to the db. //Make the query. $query = "INSERT INTO users (username, first_name, last_name, email, password, registration_date) VALUES ('$u', '$fn', '$ln', '$e', PASSWORD('$p'), NOW() )"; $result = @mysql_query ($query); //Run the query. if ($result) { // If it ran ok //Send an email, if desired. echo '<p><b>You have been registered!</b></p>'; include ('./footer.inc'); // Include the HTML footer. exit(); //Quit the script. } else { // If it did not run ok. $message = '<p>You could not be registered due to a system error. We appologise for any inconvenience.</p><p>'.mysql_error() . '</p>'; } mysql_close(); //Close the database connection. } else { $message = '<p>Please try again.</P>'; } } //End of the main Submit conditional. //Print the message if there is one. if (isset($message)) { echo '<font color="red">', $message, '</font>'; } ?> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST"> <fieldset><legend>Enter your information in the form below:</legend> <p><b>First Name:</b> <input type="text" name="first_name" size="15" maxlength="15" Value="<?php if (isset($_POST['first_name'])) echo $_POST['first_name']; ?>" /></p> <p><b>Last Name:</b> <input type="text" name="last_name" size="30" maxlength="30" Value="<?php if (isset($_POST['last_name'])) echo $_POST['last_name']; ?>" /></p> <p><b>Email Address:</b> <input type="text" name="email" size="40" maxlength="40" Value="<?php if (isset($_POST['email'])) echo $_POST['email']; ?>" /></p> <p><b>User Name:</b> <input type="text" name="username" size="10" maxlength="20" Value="<?php if (isset($_POST['username'])) echo $_POST['username']; ?>" /></p> <p><b>Password:</b> <input type="password" name="password1" size="20" maxlength="20" /></p> <p><b>Confirm Password:</b> <input type="password" name="password2" size="20" maxlength="20" /></p> </fieldset> <div align="center"><input type="submit" name="submit" value="Register" /></div> </form><!--End of Form--> include ('./footer.inc');//Include the HTML footer. ?> Quote Link to comment https://forums.phpfreaks.com/topic/69551-solved-php-html-n-mysql/ Share on other sites More sharing options...
Dragen Posted September 16, 2007 Share Posted September 16, 2007 put this at the top of the page (just below <?php) error_reporting(E_ALL); Quote Link to comment https://forums.phpfreaks.com/topic/69551-solved-php-html-n-mysql/#findComment-349493 Share on other sites More sharing options...
JJohnsenDK Posted September 16, 2007 Share Posted September 16, 2007 The mysql connection works fine you say... okay but what should be printed to the screen? which part of the code? plz post that so we can have a look at the specific code... Quote Link to comment https://forums.phpfreaks.com/topic/69551-solved-php-html-n-mysql/#findComment-349528 Share on other sites More sharing options...
papaface Posted September 16, 2007 Share Posted September 16, 2007 Change: $result = @mysql_query ($query); to $result = mysql_query ($query) or die (mysql_error()); Quote Link to comment https://forums.phpfreaks.com/topic/69551-solved-php-html-n-mysql/#findComment-349533 Share on other sites More sharing options...
coklat12 Posted September 16, 2007 Author Share Posted September 16, 2007 The mysql connection works fine you say... okay but what should be printed to the screen? which part of the code? please post that so we can have a look at the specific code... On the screen, below code will shows the text box for user to fill in. i want all input will be stored in a database by using mysql and php.. what's wrong with my codes? ..sorry i'm newbie to php. :-\ <p><b>First Name:</b> <input type="text" name="first_name" size="15" maxlength="15" Value="<?php if (isset($_POST['first_name'])) echo $_POST['first_name']; ?>" /></p> <p><b>Last Name:</b> <input type="text" name="last_name" size="30" maxlength="30" Value="<?php if (isset($_POST['last_name'])) echo $_POST['last_name']; ?>" /></p> <p><b>Email Address:</b> <input type="text" name="email" size="40" maxlength="40" Value="<?php if (isset($_POST['email'])) echo $_POST['email']; ?>" /></p> <p><b>User Name:</b> <input type="text" name="username" size="10" maxlength="20" Value="<?php if (isset($_POST['username'])) echo $_POST['username']; ?>" /></p> <p><b>Password:</b> <input type="password" name="password1" size="20" maxlength="20" /></p> <p><b>Confirm Password:</b> <input type="password" name="password2" size="20" maxlength="20" /></p> Quote Link to comment https://forums.phpfreaks.com/topic/69551-solved-php-html-n-mysql/#findComment-349566 Share on other sites More sharing options...
rarebit Posted September 16, 2007 Share Posted September 16, 2007 The html code is fine, reread 'reply #3', find first part in your code and change to include the or die bit, that will report any error's it's getting! Quote Link to comment https://forums.phpfreaks.com/topic/69551-solved-php-html-n-mysql/#findComment-349571 Share on other sites More sharing options...
coklat12 Posted September 16, 2007 Author Share Posted September 16, 2007 The html code is fine, reread 'reply #3', find first part in your code and change to include the or die bit, that will report any error's it's getting! I've changed that but still nothing appeared in a browser :-\ Quote Link to comment https://forums.phpfreaks.com/topic/69551-solved-php-html-n-mysql/#findComment-349574 Share on other sites More sharing options...
rarebit Posted September 16, 2007 Share Posted September 16, 2007 If it has an @ at the beginning (or in) of the line, then remove it, that stops errors being reported! Quote Link to comment https://forums.phpfreaks.com/topic/69551-solved-php-html-n-mysql/#findComment-349576 Share on other sites More sharing options...
coklat12 Posted September 16, 2007 Author Share Posted September 16, 2007 If it has an @ at the beginning (or in) of the line, then remove it, that stops errors being reported! I think that's not the problem.. i tried that also . but still nothing appeared in a browser. . no text , no text box.. just blank page .. :-\ Quote Link to comment https://forums.phpfreaks.com/topic/69551-solved-php-html-n-mysql/#findComment-349589 Share on other sites More sharing options...
rarebit Posted September 16, 2007 Share Posted September 16, 2007 change if ($_POST['password1'] == $_POST['password2']} { to if ($_POST['password1'] == $_POST['password2']) { Quote Link to comment https://forums.phpfreaks.com/topic/69551-solved-php-html-n-mysql/#findComment-349593 Share on other sites More sharing options...
coklat12 Posted September 16, 2007 Author Share Posted September 16, 2007 change if ($_POST['password1'] == $_POST['password2']} { to if ($_POST['password1'] == $_POST['password2']) { goshh its works! . thanks dude! . just a typo mistake . thanks all Quote Link to comment https://forums.phpfreaks.com/topic/69551-solved-php-html-n-mysql/#findComment-349598 Share on other sites More sharing options...
rarebit Posted September 16, 2007 Share Posted September 16, 2007 When there's nothing there, that's what it normally is... Quote Link to comment https://forums.phpfreaks.com/topic/69551-solved-php-html-n-mysql/#findComment-349599 Share on other sites More sharing options...
coklat12 Posted September 16, 2007 Author Share Posted September 16, 2007 When there's nothing there, that's what it normally is... oo i see .. okay thanks for help. Quote Link to comment https://forums.phpfreaks.com/topic/69551-solved-php-html-n-mysql/#findComment-349600 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.