Jump to content

Smee

Members
  • Posts

    55
  • Joined

  • Last visited

    Never

Everything posted by Smee

  1. Ah sorry will do from now on. Well i have changed the error tags and now it just gets my last variable echo of "Please try again" everytime i enter any data. Thanks for any help <?php if (eregi ('^[[:alpha:]\.\'\-]{2,15}$', stripslashes(trim($_POST['first_name'])))) { $fn = mysql_real_escape_string($_POST['first_name']); } else { $fn = FALSE; echo '<p><font color ="red" size="+1"> Please enter your first name!</font></p>'; } if (eregi ('^[[:alpha:]\.\'\-]{2,30}$', stripslashes(trim($_POST['last_name'])))) { $fn = mysql_real_escape_string($_POST['last_name']); } else { $ln = FALSE; echo '<p><font color ="red" size="+1"> Please enter your last name!</font></p>'; } if (eregi ('^[[:alnum:]][a-z0-9_\.\-]*@[a-z0-9\.\-]+\.[a-z]{2,4}$', stripslashes(trim($_POST['email'])))) { $e = mysql_real_escape_string($_POST['email']); } else { $e = FALSE; echo '<p><font color ="red" size="+1"> Please enter a correct e-mail address</font></p>'; } if (eregi ('^[[:alnum:]]{4,20}$', stripslashes(trim($_POST['password1'])))) { if ($_POST['password1'] == $_POST['password2']) { $p = mysql_real_escape_string($_POST['password1']); } else { $p = FALSE; echo '<p><font color ="red" size="+1"> Your password did not match the confirmed password!</font></p>'; } } else { $p = FALSE; echo '<p><font color ="red" size="+1"> Please enter a valid password!</font></p>'; } if ($fn && $ln && $e && $p) { $query ="SELECT username FROM users WHERE email='$e'"; $result = mysql_query ($query) or trigger_error("Query: $query\n<br />MySQL Error: ".mysql_error()); if (mysql_num_rows($result) == 0) { $a = md5(uniqid(rand(), true)); $query = "INSERT INTO users (email, pass, first_name, last_name, active, registration_date) VALUES ('$e', '$p', $'f', $'ln', $'a' )"; $result = mysql_query ($query) or trigger_error("Query: $query\n<br />MySQL Error:" .mysql_error()); if (mysql_affected_rows() == 1) { $body = "Thank you for registering with Football Trip. Please use the link below to activate your account:\n\n"; $body .= "http://www.footballtrip.net/activate.php?x=" . mysql_insert_id() . "&y=$a"; mail($_POST['email'],'Registration Comfirmation',$body); echo '<h2> Thank you for registering! A confirmation E-Mail has been sent to your address. Please click on the link in order to activate your account</h2>'; } else { echo '<p>font color="red" size="+1"> You could not be registered due to a system error. We apologize for any inconvenience. </font></p>'; } } else { echo '<p><font color="red" size="+1"> That E-Mail address has already been registered. If you have forgotten your password, use the link to have your password sent to you.</font></p>'; } } else { echo '<p><font color="red" size="+1"> Please try again.</font></p>'; } mysql_close(); ?>
  2. Hey All, i have been working on a website to try and get me used to PhP. By using several books i have got the hang of most parts but i cant for the life of me understand why i keep getting the same problems. First name and Last names always show as an error even if you enter something in the field. when i enter all fields i get an escape_data() error. I just cant get it past these two significant parts. Thanks for any help because im getting very far at the moment [attachment deleted by admin]
  3. Hey All Wondering if someone could give me some advice on what im doing wrong with my coding. session_start(); // Start Session $username = $_SESSION["user"]; $username = $_GET['username']; $conn=mysql_connect("","",""); mysql_select_db(""); $result = mysql_query ("SELECT * FROM friends WHERE ('$_SESSION[user]', '$_GET[username]')"); if (mysql_query($result) == 1) { echo " You are already friends "; } else mysql_query ("INSERT INTO friends (me, friend) VALUES ('$_SESSION[user]', '$_GET[username]')"); ?> Later on in the page i have this to show the information. <?php echo " Friend <b>$_GET[username]</b> Added <br />"; echo " <br />"; echo " <a href='mainpage.php'> Back </a> "; mysql_close() ?> I am trying to get a message to show when friends already appear in the me/friend table, if not then insert into the table. I am passing my logged in username through $_SESSION[user] and the friend username through hyper link on the pervious page named hence the $_GET[username]. I'm sure this is really simple for most people but i've just started and keep going round in circles. Am i even close Thanks for Any help Smee
  4. Wow that was easy.. Thanks for that Cant belive all i didn't put was the {} around $row['friend'] when i was trying so many variations! dont suppose you could explain why they are needed there? Thanks again
  5. Hey All, I'm new to PHP and was wondering if someone could help me out. Im currently creating a friends list that shows added friends to users that are logged in. <?php $result = mysql_query ("SELECT * FROM friends WHERE me = '$username'"); ($row = mysql_fetch_array($result)); echo " <b>Username:</b> $row[friend] </br> "; ?> Above is the query i created that shows my freinds but because of the setup of SQL database i am only getting one result showing. SQL database is setup like this: me friend username friendsusername When multiple usernames are the same it only shows the most current friend when displayed on my main page. I have tried to do some while loops but to no avail. Bascally i just need to keep it as simple as possible but display all friends under a certain username. Thanks for any help Smee
×
×
  • 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.