Jump to content

frijole

Members
  • Posts

    214
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

Contact Methods

  • Yahoo
    joelklabo

frijole's Achievements

Regular Member

Regular Member (3/5)

0

Reputation

  1. thanks for the link. I am trying to use the box to display a register form. When I try to use my register.php file in the box, nothing shows up. Is there some special set-up for PHP files in the box?
  2. I am trying to get a register form to pop out when the link is clicked. replacing the log in form. Does anyone know a way to do this?
  3. sorry, that feature was disabled last time i was on the site. Thanks again.
  4. I am still working on my login script. I am trying to get the username of the person who signed to display on the front page that the form redirects to. I have a <?php echo $_SESSION['userName']; ?> on the front page. But, nothing is displayed. I can't tell why. <?php ob_start(); // buffer the output require_once 'dbConnect.php'; require_once 'functions.php'; $error = ''; if ($_POST['logIn'] == 1) { //if the form has been submitted $userName = $_POST['user']; $pass = $_POST['pass']; $query = "SELECT * FROM users WHERE user_name='$userName' AND user_pass='$pass'"; $result = mysql_query($query) or die("connection error."); if (empty($userName) || empty($pass)) { //are any of the fields empty $error = "All fields must be filled out.";} elseif (mysql_num_rows($result) != 1) { //if the username and password combo are not valid $error = "Invalid username, password combo.";} else { //log in was successful if (keepLogged ==1) { $year = 525600 + time(); setcookie(thinksnack, 1, $year); } $_SESSION['userName'] = $userName; $_SESSION['loggedIn'] = 1; header('Location: http://www.thinksnack.com/index.php'); } } showLogInForm ($error); ob_end_flush(); // dump the buffer ?>
  5. I am working on a log in script and I am trying to redirect the user back to the front page once they have logged in. This is my log in Script, followed by the attached functions: I would really appreciate some guidance if anyone has seen this before. <?php require_once 'dbConnect.php'; require_once 'functions.php'; $error = ''; if ($_POST['logIn'] == 1) { //if the form has been submitted $userName = $_POST['user']; $pass = $_POST['pass']; $query = "SELECT * FROM users WHERE user_name='$userName' AND user_pass='$pass'"; $result = mysql_query($query) or die("connection error."); if (empty($userName) || empty($pass)) { //are any of the fields empty $error = "All fields must be filled out.";} elseif (mysql_num_rows($result) != 1) { //if the username and password combo are not valid $error = "Invalid username, password combo.";} else { //log in was successful if (keepLogged ==1) { $year = 525600 + time(); setcookie(thinksnack, 1, $year); } $_SESSION['userName'] = $userName; $_SESSION['loggedIn'] = 1; header('Location: http://www.thinksnack.com/'); } } showLogInForm ($error); ?> <?PHP function showRegisterForm ($error) { echo $error; ?> <fieldset> <legend>Register</legend> <table> <form name="input" action="<?php echo $_SERVER['PHP_SELF'] ?>" method="post"> <tr> <td>Username: </td> <td><input type="text" name="user"></td> </tr> <tr> <td>Password:</td> <td><input type="password" name="pass"></td> </tr> <tr> <td>Password:</td> <td><input type="password" name="rePass"></td> </tr> <tr> <input type="hidden" name="register" value="1"> <td><input type="submit" value="Submit"></td> </tr> </form> </table> </fieldset> <?PHP }?> <?PHP function showLogInForm ($error) { echo $error; ?> <table> <form name="input" action="<?php echo $_SERVER['PHP_SELF'] ?>" method="post"> <tr> <td>username </td><td>password</td><td>stay logged in<input type="checkbox" name="keepLogged" value="1"></td> </tr><tr> <td><input type="text" name="user"></td> <td><input type="password" name="pass"></td> <input type="hidden" name="logIn" value="1"> <td><input type="submit" value="Submit"></td> </tr> </form> </table> <?php } ?>
  6. sweet, that's exactly it. Thank a lot!
  7. I am not sure if this effect is js or not. Does anyone know how to create the effect where you clink the register link on a sire and instead of opening up a new page it displays a box on top of the current page, and the background grays out a little? I am trying to find a tutorial or something, but it is hard to describe. Have you guys seen or know anything about setting that up?
  8. it's fixed! thanks so much guys. You've really been a huge help.
  9. ok, thank you so much for the help. Now it is inserting the data but it is inserting $userName as the username instead of the value that it holds.
  10. here is the error errorUnknown column '$userName' in 'field list'
  11. here is what I have now and it is acting as if it was successful, no error. It echoes "You have been successfully added" I don't get it. <?php //Database Settings $host = "localhost"; $dbUser = "thinksna"; $pass = "******"; $DB = "thinksna_db"; //MySQL Connection $conn = mysql_connect($host, $dbUser, $pass); if (!conn) { // the connection failed so quit the script die('Could not connect !<br />Please contact the site administrator.'); } $db = mysql_select_db($DB, $conn); if (!db) { // cannot connect to the database so quit the script die('Could not connect to database <br /> Please contact the site administrator.'); } //this script registers a new user. require_once 'functions.php'; $error = ''; if ($_POST['register'] == 1) { //if the form has been submitted $userName = $_POST['user']; $pass = $_POST['pass']; $rePass = $_POST['rePass']; $query = 'SELECT * FROM users WHERE user_id="$userName"'; $insertUser = 'INSERT INTO users VALUES ($userName, $pass)'; if (empty($userName) || empty($pass) || empty($rePass)) { //are any of the fields empty $error = "All fields must be filled out.";} elseif ($pass != $rePass) { //all fileds are filled out, are the values valid? $error = "The passwords do not match.";} elseif (strlen($pass) < 4 || strlen($pass) > 12) { //check if username is too long or too short $error = "You password must be between 4 and 12 characters long.";} elseif (strlen($userName) < 4 || strlen($userName) > 12) { //check if username is too long or too short $error = "You username must be between 4 and 12 characters long.";} elseif (preg_replace('/[\w ]/', '', $userName)) { //check for invalid characters in the username $error = "Your username may only contain letters, numbers, or underscores";} else { //check if username already exists $result = mysql_query($query) or mysql_error($conn); if (mysql_num_rows($result) > 0) { $error = "That username is already taken."; } else { //add user to the database if (strlen($error) > 0) { showRegisterForm($error); } else { $result = mysql_query($insertUser) or mysql_error($conn); echo 'You have been added! sign-in and enjoy.'; } } } //show form and errors if applicable } showRegisterForm($error); ?>
  12. so I would replace die with a mysql_error()?
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.