Jump to content

cc9of13

New Members
  • Posts

    6
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

cc9of13's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Hello again. I am a web development student, currently studying PHP. I've been trying to get this script to work correctly for days and still no luck. I'm not sure if my issue is with the script or maybe a php.ini setting related to the mail server. Anyway, this is a simple registration form. It accepts input and adds it to the DB, but it does not send the activation email or redirect me to "thanks for registering page. Does anyone have any input? I truly appreciate it! <?php // register.php // Include the configuration file for error management and such. require_once ('./includes/config.inc.php'); // Set the page title and include the HTML header. $page_title = 'Register'; include ('./includes/header.html'); // Handle the form. if (isset($_POST['submitted'])) { // Connect to the database. require_once ('includes/mysql_connect.php'); // Check for a first name. if (preg_match("/^[A-Za-z’ -]{2,15}$/i", stripslashes(trim($_POST ['first_name'])))) { $fn = escape_data($_POST ['first_name']); } else { $fn = false; echo '<p><font color="red" size="+1">Please enter your first name!</font></p>'; } // Check for a last name. if (preg_match("/^[A-Za-z’ -]{2,30}$/i", stripslashes(trim($_POST ['last_name'])))) { $ln = escape_data($_POST ['last_name']); } else { $ln = false; echo '<p><font color="red" size="+1">Please enter your last name!</font></p>'; } // Check for an email address. if(preg_match("/^.+@.+\\..+$/i", stripslashes(trim($_POST ['email'])))) { $e = escape_data($_POST['email']); } else { $e = false; echo '<p><font color="red" size="+1">Please enter a valid email address!</font></p>'; } // Check for a password and match against the confirmed password. if (preg_match("/^[a-z0-9]{4,20}$/i", stripslashes(trim($_POST ['pass'])))) { if ($_POST['pass'] = $_POST['pass2']) { $p = escape_data($_POST ['pass']); } 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 everything's OK. if ($fn && $ln && $e && $p) { // If everything's OK. // Make sure the email address is available. $query = "SELECT user_id 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) { // Create the activation code. $a = md5(uniqid(rand(), true)); // Add the user. $query = "INSERT INTO users (email, pass, first_name, last_name, active, registration_date) VALUES ('$e', SHA('$p'), '$fn', '$ln','$a', NOW() )"; $result = mysql_query ($query) or trigger_error("Query: $query\n<br/>MySQL Error: " . mysql_error()); if (mysql_affected_rows()== 1) { // Send the email. $body = "Thank you for registering. To activate your account, please click on this link:\n\n"; $body .= "http://localhost/activate.php?x=" . mysql_insert_id() . "&y=$a\n\n"; $body .= "We appreciate your interest. \n\n"; $body .= "If you have any questions or problems,"; $body .= " email myemail@gmail.com"; $subj = "Your new customer registration"; mail($_POST['email'], $subj, $body, 'From: MCMjuly@gmail.com'); // Finish the page. echo '<h3>Thank you for registering! A confirmation email has been sent to your address. Please click on the link in that email in order to activate your account.</h3>'; include ('./includes/footer. html'); // Include the HTML footer. exit(); } else { // If it did not run OK. 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 { // The email address is not available. echo '<p><font color="red" size="+1">That email address has already been registered. If you have forgotten your password,use the link to have your password sent to you.</font></p>'; } } else { // If one of the data tests failed. echo '<p><font color="red" size="+1">Please try again.</font> </p>'; } mysql_close(); // Close the database connection. } // End of the main Submit conditional. ?> <h1>Register</h1> <form action="register.php" method="post"> <fieldset> <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>Password:</b> <input type="password" name="pass" size="20" maxlength="20" /> <small>Use only letters and numbers. Must be between 4 and 20 characters long.</small></p> <p><b>Confirm Password:</b><input type="password" name="pass2"size="20" maxlength="20" /></p> </fieldset> <div align="center"><input type="submit" name="submit" value="Register" /></div> <input type="hidden" name="submitted" value="TRUE" /> </form> <?php include ('./includes/footer.html'); ?>
  2. Thanks bluejay. I moved the uploads directory to the web root and it worked just fine with this code: echo "<img src=\"/uploads/{$_GET['image']}\" $image[3] border=\"2\" />"; I guess I got thrown off because the text I was working from said it was perfectly o.k. to keep upload folder in directory other than the web root (for security purposes). I am sure that there is a way to do that, but I have had no luck figuring it out. Thanks again for your help. God Bless, CC
  3. Thanks again bluejay. I believe $_GET['image'] is defined in the companion document, images.php with this code: // Set the window properties. var window_specs = "location=no, scrollbars=no, menubars=no, toolbars=no, resizable=yes, left=0, top=0, width=" + width + ", height=" + height; // Set the URL. var url = "image_window.php?image=" + image; During my debugging efforts, I tried to address the same question, but I wasn't exactly sure if $_GET['image'] had to be defined in the image_window script or if PHP knows that it was defined in the images.php script (don't forget, I am still learning). I have attached the full images.php. CC [attachment deleted by admin]
  4. oh, i should probably mention the image name: FULL PATH: C:/xampp/uploads/cbstar.gif
  5. Thanks for your help bluejay. I tried both examples you gave (I worked on the escaping quite a bit when I was trying to debug on my own). However, when using the backslashes, I then get this error: This script must receive a valid image name! Maybe that's the error I should have been addressing in the first place???? Thanks again. CC
  6. Hello. I'm a new user to this forum and a web development student. During my studies I have often searched tech forums for answers, but this is the first time I've registered....because I am currently learning PHP....and I like it, so I really want to understand it. This is my current issue: (I have reseached this error extensively...and cannot solve it). Here is the error: Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in …\image_window.php on line 23 Line 23 = echo "<img src="C:/xampp/uploads/{$_GET['image']}\" $image[3] border=\"2\" />"; This code is from a text book, other than the directory path referred to in line 23. HERE IS THE CODE: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"xml:lang="en"lang="en"> <head> <meta http-equiv="content-type" content="text/html; charset=iso-8859-1" /> <title>View Image</title> </head> <body> <?php # image_window.php // Set a variable for problem reporting. $okay = FALSE; // Make sure an image name was passed to the script. if (isset($_GET['image'])) { // Get the extension of the image name. $ext = substr ($_GET['image'], -4); // Test if it's a valid image extension. if ((strtolower($ext) == '.jpg') OR (strtolower($ext) == 'jpeg') OR (strtolower($ext) == '.gif')) { // Get the image information and display the image. if ($image = @getimagesize ('uploads/' . $_GET['image'])) { echo "<img src="C:/xampp/uploads/{$_GET['image']}\" $image[3] border=\"2\" />"; $okay = TRUE; // No problems. } } // End of extension IF. } // End of isset() IF. // If something went wrong... if (!$okay) { echo '<div align="center"><font color="red" size="+1">This script must receive a valid image name!</font></div>'; } ?> <br /> <div align="center"><a href="javascript:self.close();">Close This Window</a></div> </body> </html> Any insight would truly be appreciated. Thank you! CC
×
×
  • 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.