sandia82 Posted September 24, 2009 Share Posted September 24, 2009 I created this signup page, but it is not connecting to the database. What am I missing? Here is the coding I have. <?php // Insert the page header $page_title = 'Sign Up'; require_once('header.php'); require_once('appvars.php'); require_once('connectvars.php'); // Connect to the database $dbc = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME); if (isset($_POST['submit'])) { // Grab the profile data from the POST $username = mysqli_real_escape_string($dbc, trim($_POST['Username'])); $password1 = mysqli_real_escape_string($dbc, trim($_POST['Password1'])); $password2 = mysqli_real_escape_string($dbc, trim($_POST['Password2'])); if (!empty($username) && !empty($password1) && !empty($password2) && ($password1 == $password2)) { // Make sure someone isn't already registered using this username $query = "SELECT * FROM UCT_MembersInfo WHERE username = '$username'"; $ = mysqli_query($dbc, $query); if (mysqli_num_rows($data) == 0) { // The username is unique, so insert the data into the database $query = "INSERT INTO UCT_MembersInfo (Username, Password, CreateDate) VALUES ('$Username', SHA('$Password1'), NOW())"; mysqli_query($dbc, $query); // Confirm success with the user echo '<p>Your new account has been successfully created. You\'re now ready to <a href="index.php">log in</a>.</p>'; mysqli_close($dbc); exit(); } else { // An account already exists for this username, so display an error message echo '<p class="error">An account already exists for this username. Please create a different username.</p>'; $username = ""; } } else { echo '<p class="error">You must enter all of the sign-up data, including the desired password twice.</p>'; } } mysqli_close($dbc); ?> <p>Please enter your username and desired password to sign up to the Ultimate Casting Team Site.</p> <form method="post" action="<?php echo $_SERVER['QUERY_STRING']; ?>"> <fieldset> <legend>Registration Info</legend> <label for="username">Username:</label> <input type="text" id="username" name="username" value="<?php if (!empty($username)) echo $username; ?>" /><br /> <label for="password1">Password:</label> <input type="password" id="password1" name="password1" /><br /> <label for="password2">Password (retype):</label> <input type="password" id="password2" name="password2" /><br /> </fieldset> <input type="submit" value="Sign Up" name="submit" /> </form> <?php // Insert the page footer require_once('footer.php'); ?> Quote Link to comment https://forums.phpfreaks.com/topic/175316-php-signup-is-not-working/ Share on other sites More sharing options...
Maq Posted September 24, 2009 Share Posted September 24, 2009 How do you know it's not connecting? What is this line? $ = mysqli_query($dbc, $query); Note: Please use tags. Quote Link to comment https://forums.phpfreaks.com/topic/175316-php-signup-is-not-working/#findComment-923942 Share on other sites More sharing options...
sandia82 Posted September 24, 2009 Author Share Posted September 24, 2009 Here is the error that I am getting: Parse error: syntax error, unexpected '=', expecting T_VARIABLE or '$' in /home8/ultimaz7/public_html/signup.php on line 21 I was working on it yesterday and it would create the username and password and it told me: "You must enter all of the sign-up data, including the desired password twice." The site is http://www.ultimatecastingteam.com/ Quote Link to comment https://forums.phpfreaks.com/topic/175316-php-signup-is-not-working/#findComment-924203 Share on other sites More sharing options...
Maq Posted September 24, 2009 Share Posted September 24, 2009 $ = mysqli_query($dbc, $query); Should be: $data = mysqli_query($dbc, $query); Quote Link to comment https://forums.phpfreaks.com/topic/175316-php-signup-is-not-working/#findComment-924342 Share on other sites More sharing options...
sandia82 Posted September 24, 2009 Author Share Posted September 24, 2009 Now I'm getting these two errors: Warning: mysqli_connect() [function.mysqli-connect]: (HY000/2005): Unknown MySQL server host 'DB_HOST' (1) in /home8/ultimaz7/public_html/signup.php on line 10 Warning: mysqli_close() expects parameter 1 to be mysqli, boolean given in /home8/ultimaz7/public_html/signup.php on line 44 Quote Link to comment https://forums.phpfreaks.com/topic/175316-php-signup-is-not-working/#findComment-924360 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.