Jump to content

scm22ri

Members
  • Posts

    89
  • Joined

  • Last visited

Everything posted by scm22ri

  1. Hi Everyone, I'm having trouble with php form validation. If a user clicks on "submit" after they no input boxes their information is automatically submitted into my mysql database. I don't want that. I want it so if a person forgets to fill out a certain part of the form they get presented with a error but there information isn't submitted into my mysql database. Any help would you appreciated. Thanks Everyone! http://whatsmyowncarworth.com/class-work/sign2/join.php
  2. Thanks niel, Why are you storing the users password in a session. You should never do this. You should store something that can tie them up to the database such as their ID. I'm not sure. I tried the code this way and it worked so I stuck with it. Should I change session_register("mypassword"); to session_register("id"); ? Also, thanks Christain! Thanks!
  3. Hi Neil, Thanks for the reply and help but I'm a little confused. On my car-search.php my syntax is below for the referring URL. <?php $curl = $_SERVER['REQUEST_URI']; // <--- This will get that page's url. $_SESSION['crurl']= "$curl"; // <--- now storing it in a variable for later usage ?> Where on my checklogin.php page (where all of my users are checked before they are logged) should I put the syntax you've provided me? My syntax as it stands now. <?php // ob_start(); include_once "connect_to_mysql.php"; // Define $myusername and $mypassword $myusername=$_POST['myusername']; $mypassword=$_POST['mypassword']; // To protect MySQL injection (more detail about MySQL injection) $myusername = stripslashes($myusername); $mypassword = stripslashes($mypassword); $myusername = mysql_real_escape_string($myusername); $mypassword = mysql_real_escape_string($mypassword); $sql="SELECT * FROM users WHERE username='$myusername' and password='$mypassword'"; $result=mysql_query($sql); // Mysql_num_row is counting table row $count=mysql_num_rows($result); // If result matched $myusername and $mypassword, table row must be 1 row if($count==1){ // Register $myusername, $mypassword and redirect to file "login_success.php" // session_register has been depreciated. Must figure use another function? session_register("myusername"); session_register("mypassword"); // $_SESSION["myusername"]; // $_SESSION["mypassword"]; header("location:bo.php"); } else { echo "Wrong Username and Password"; } // ob_end_flush(); ?>
  4. Hi Everyone, I have a question regarding php redirects. If you visit the below URL and if your not logged in - your presented with a statement saying you have to be logged in (which is what I want) but after the person clicks on "Click Here" they are taken to the login page where they can login. My question is, how would I redirect visitors back to the car-search page they originally wanted to visit? http://whatsmyowncar.../car-search.php This is my php session syntax on the car-search.php page. <?php session_start(); if (!isset($_SESSION['myusername'])) { echo "Hello, you must have an account to view this page. <a href=\"http://whatsmyowncarworth.com/class-work/sign2/main_login.php\">Click Here</a>!<br>"; exit(); } ?>
  5. Correct if I'm wrong but I would have to put my comparison in other if statement? I just tried with all if statements (below) and the code isn't working. if((!$username) || (!$country) || (!$state) || (!$city) || (!$email) || (!$email2) || (!$password) || (!$password2) ){ $errorMsg = "You did not submit the following required information!<br /><br />"; if (!$username){ $errorMsg .= "--- User Name<br/>"; } if (!$country){ $errorMsg .= "--- Country<br/>"; } if (!$state){ $errorMsg .= "--- State<br/>"; } if (!$city){ $errorMsg .= "--- City<br/>"; } if ($email !== $email2){ $errorMsg .= 'ERROR: Your Email fields below do not match<br />'; } if ($password !== $password2){ $errorMsg .= 'ERROR: Your Password fields below do not match<br />'; } } Thanks
  6. Hi Everyone, I'm having a hard time confirming passwords in my sign up form. My email confirming is working fine but if a user signs up for my website with two different passwords they automatically get signed up. In other words, my error checking isn't taking care of the problem. I've been working on this for quite a while and not sure what the problem is. Any help would be appreciated it. Thanks. http://whatsmyowncar...n/join_form.php <?php // Set error message as blank upon arrival to page // This is a function that I can apply to any words/phrases function letscapthis($element){ $element = strtolower($element); return ucwords($element); } // Above is the function called "letscapthis" $errorMsg = ""; // First we check to see if the form has been submitted if (isset($_POST['username'])){ //Connect to the database through our include include_once "connect_to_mysql.php"; // Filter the posted variables $username = ereg_replace("[^A-Za-z0-9]", "", $_POST['username']); // filter everything but numbers and letters $country = ereg_replace("[^A-Z a-z0-9]", "", $_POST['country']); // filter everything but spaces, numbers, and letters $state = ereg_replace("[^A-Z a-z0-9]", "", $_POST['state']); // filter everything but spaces, numbers, and letters $state = letscapthis($state); $city = ereg_replace("[^A-Z a-z0-9]", "", $_POST['city']); // filter everything but spaces, numbers, and letters $city = letscapthis($city); $email = stripslashes($_POST['email']); $email = strip_tags($email); $email = mysql_real_escape_string($email); $email2 = stripslashes($_POST['email2']); $email2 = strip_tags($email2); $email2 = mysql_real_escape_string($email2); $password = ereg_replace("[^A-Za-z0-9]", "", $_POST['password']); // filter everything but numbers and letters $password2 = ereg_replace("[^A-Za-z0-9]", "", $_POST['password2']); // filter everything but numbers and letters // Check to see if the user filled all fields with // the "Required"(*) symbol next to them in the join form // and print out to them what they have forgotten to put in if((!$username) || (!$country) || (!$state) || (!$city) || (!$email) || (!$email2) || (!$password) || (!$password2) ){ $errorMsg = "You did not submit the following required information!<br /><br />"; if(!$username){ $errorMsg .= "--- User Name"; } if(!$country){ $errorMsg .= "--- Country"; } if(!$state){ $errorMsg .= "--- State"; } if(!$city){ $errorMsg .= "--- City"; } else if($email !== $email2){ $errorMsg = 'ERROR: Your Email fields below do not match<br />'; } else if($password !== $password2){ $errorMsg = 'ERROR: Your Password fields below do not match<br />'; } } else { // Database duplicate Fields Check $sql_username_check = mysql_query("SELECT id FROM members WHERE username='$username' LIMIT 1"); $sql_email_check = mysql_query("SELECT id FROM members WHERE email='$email' LIMIT 1"); $username_check = mysql_num_rows($sql_username_check); $email_check = mysql_num_rows($sql_email_check); if ($username_check > 0){ $errorMsg = "<u>ERROR:</u><br />Your User Name is already in use inside our system. Please try another."; } else if ($email_check > 0){ $errorMsg = "<u>ERROR:</u><br />Your Email address is already in use inside our system. Please try another."; } else { // Add MD5 Hash to the password variable $hashedPass = md5($password); // Add user info into the database table, claim your fields then values $sql = mysql_query("INSERT INTO members (username, country, state, city, email, password, signupdate) VALUES('$username','$country','$state','$city','$email','$hashedPass', now())") or die (mysql_error()); echo 'Thanks for submitting your information.<br /><br /> To return to the homepage, <a href="index.php">click here</a>'; } // Close else after database duplicate field value checks } // Close else after missing vars check } //Close if $_POST ?>
  7. Hi Everyone, I'm trying to get rid of the 0,1,2 etc ... in-front of my parameters when I display data from my array. Any help here would be appreciated. Thanks everyone! http://whatsmyowncar...week4/while.php (bottom example) $newschannels = array('Local'=>array('ABC6 News','CBS Stations','Local Fox News','NBC News'), 'Regional'=>array('YES Network','NESN'), 'National'=>array('Fox News','CNN','MSNBC'), 'International'=>array('BBC News','France International','Ireland International')); foreach($newschannels as $channels => $data){ echo "$channels".'<br>'; foreach($data as $key => $value){ echo "Region: $key, Channel: $value".'<br>'; } }
  8. Hi Everyone, I want to display the vehicles every user is selling but for some reason I'm getting duplicate information. I think the answer to my question is the array_unique function but I'm having a hard time trying to figure out where the function should go? Any help would be appreciated. Thanks <?php include_once "init.php"; echo "<table border='1'>"; echo "<tr> <th>User ID</th> <th>First Name</th> <th>Last Name</th> <th>Car Desc ID</th> <th>Price</th> <th>Mileage</th> <th>Transmission</th> <th>Color</th> <th>Year</th> <th>Make</th> <th>Model</th> </tr>"; $query = "SELECT users.user_id, users.firstname, users.lastname, prices.car_desc_id, prices.price, \n" . "\n" . "prices.mileage, prices.transmission, prices.color, car_desc.year, car_desc.make, car_desc.model\n" . "\n" . "FROM users, prices, car_desc\n" . "\n" . "WHERE prices.car_desc_id LIMIT 0, 30 "; // $result = array_unique($query); // $query = "SELECT * FROM car_desc ORDER BY id ASC"; $thedude = mysql_query($query) or die(mysql_error()); // $result = array_unique($thedude); while ($row = mysql_fetch_array($thedude)) { $user_id = ($row['user_id']); $firstname = ($row['firstname']); $lastname = ($row['lastname']); $car_desc_id = ($row['car_desc_id']); $price = ($row['price']); $mileage = ($row['mileage']); $transmission = ($row['transmission']); $color = ($row['color']); $year = ($row['year']); $make = ($row['make']); $model = ($row['model']); // keeps getting the next row until there are no more to get /*while ($row = mysql_fetch_array($result))*/ { // Print out the contents of each row into a table ?> <tr> <td><?php echo "$user_id"; ?></td> <td><?php echo "$firstname"; ?></td> <td><?php echo "$lastname"; ?></td> <td><?php echo "$car_desc_id"; ?></td> <td><?php echo "$price"; ?></td> <td><?php echo "$mileage"; ?></td> <td><?php echo "$transmission"; ?></td> <td><?php echo "$color"; ?></td> <td><?php echo "$year"; ?></td> <td><?php echo "$make"; ?></td> <td><?php echo "$model"; ?></td> </tr> <?php } /*echo "</table>";*/ } /*else*/ { /*trigger_error(mysql_error()); // for development only; remove when in production*/ } ?>
  9. Hi Everyone, What I'm trying to accomplish is this, I want to display the vehicles every user is selling but for some reason I'm getting duplicate information. I think the answer to my question is the array_unique function but I'm having a hard time trying to figure out where the function should go? Any help would be appreciated, thanks! http://www.whatsmyowncarworth.com/for-sale/mysql/mysql-command.php <?php include_once "init.php"; echo "<table border='1'>"; echo "<tr> <th>User ID</th> <th>First Name</th> <th>Last Name</th> <th>Car Desc ID</th> <th>Price</th> <th>Mileage</th> <th>Transmission</th> <th>Color</th> <th>Year</th> <th>Make</th> <th>Model</th> </tr>"; $query = "SELECT users.user_id, users.firstname, users.lastname, prices.car_desc_id, prices.price, \n" . "\n" . "prices.mileage, prices.transmission, prices.color, car_desc.year, car_desc.make, car_desc.model\n" . "\n" . "FROM users, prices, car_desc\n" . "\n" . "WHERE prices.car_desc_id LIMIT 0, 30 "; // $result = array_unique($query); // $query = "SELECT * FROM car_desc ORDER BY id ASC"; $thedude = mysql_query($query) or die(mysql_error()); // $result = array_unique($thedude); while ($row = mysql_fetch_array($thedude)) { $user_id = ($row['user_id']); $firstname = ($row['firstname']); $lastname = ($row['lastname']); $car_desc_id = ($row['car_desc_id']); $price = ($row['price']); $mileage = ($row['mileage']); $transmission = ($row['transmission']); $color = ($row['color']); $year = ($row['year']); $make = ($row['make']); $model = ($row['model']); // keeps getting the next row until there are no more to get /*while ($row = mysql_fetch_array($result))*/ { // Print out the contents of each row into a table ?> <tr> <td><?php echo "$user_id"; ?></td> <td><?php echo "$firstname"; ?></td> <td><?php echo "$lastname"; ?></td> <td><?php echo "$car_desc_id"; ?></td> <td><?php echo "$price"; ?></td> <td><?php echo "$mileage"; ?></td> <td><?php echo "$transmission"; ?></td> <td><?php echo "$color"; ?></td> <td><?php echo "$year"; ?></td> <td><?php echo "$make"; ?></td> <td><?php echo "$model"; ?></td> </tr> <?php } /*echo "</table>";*/ } /*else*/ { /*trigger_error(mysql_error()); // for development only; remove when in production*/ } ?>
  10. Hi Everyone, The content of my website is going beyond the <section> border. I tried expanding my CSS section width but it doesn't want to work. What am I doing wrong? Thanks! http://whatsmyowncarworth.com/classTemplate/sales.php @charset "UTF-8"; /* CSS Document */ body{ background-color:#000; text-align:center; font-family:"Century Gothic",Verdana, Geneva, sans-serif; color:#555; } #container{ width:950px; margin:35px auto; background-color:#fff; } header{ padding:15px; width:950px; } nav{ height:50px; width:100%; border-top: 1px solid #ccc; border-bottom: 1px solid #ccc; } nav ul{ margin:13px; padding:0px; } nav ul li{ display:inline; list-style-type:none; margin:15px 45px; } nav ul li a { text-decoration:none; color:#800000; padding:15px; } nav ul li a:hover{ background-color:#ccc; } section{ min-height:650px; min-width:700px; } footer{ }
  11. Hi Everyone, Is it possible to join 2 or more tables while grabbing data from a mysql database? Thanks
  12. Hi Thorpe, My mistake. I can sometimes ramble on. My question is this, I want to add the state that's associated with the city in the URL. How would I do that? I want the URLS to look like this. (the below URLS don't work) http://whatsmyowncarworth.com/auto/albany/new-york http://whatsmyowncarworth.com/auto/Miami/florida http://whatsmyowncarworth.com/auto/providence/rhode-island These are currently working. http://whatsmyowncarworth.com/auto/Miami http://whatsmyowncarworth.com/auto/providence http://whatsmyowncarworth.com/auto/albany Thanks
  13. Hi Everyone, I'm trying to append another value onto my URL that I'm dynamically inserting via php syntax, I'm having trouble trying to figure it out. I'm trying to append the a "state" onto my URL. In the below URL is my information where I'm pulling my data http://whatsmyowncarworth.com/auto/display-information.php In the few URLS below is where I'm getting the "city" and appending it to the URL. (my php syntax is below) http://whatsmyowncarworth.com/auto/Miami http://whatsmyowncarworth.com/auto/providence http://whatsmyowncarworth.com/auto/albany What I'm trying to do is this, I want each URL to have a "state" value so I want the URLS to look like this, http://whatsmyowncarworth.com/auto/albany/new-york http://whatsmyowncarworth.com/auto/Miami/florida http://whatsmyowncarworth.com/auto/providence/rhode-island This is my syntax and below that is my .htaccess code. Any help would be great. Thanks everyone! <?php include('init.php'); // connection to database // if city exists... if (isset($_GET['u'])) { // decode and replace hyphen with space $city = str_replace('-','',urldecode($_GET['u'])); // if value contains only letters, numbers or spaces... if ( preg_match('~^[a-z0-9 ]+$~i',$city) ) { // select data from database... $data = mysql_query("SELECT State, City FROM cars WHERE City='$city'" ); if (mysql_num_rows($data) > 0) { while ($row = mysql_fetch_assoc($data)) { echo $row["City"]; echo $row["State"]; } } } } ?> >>>>>>>>>>>>>>>>> .htaccess RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ /auto/cars.php?u=$1 [NC]
  14. Hi Everyone, I'm not entirely sure how images would work with php. The images these types of websites have (below) do you believe the images are stored in a mysql database and called like everything else or are they stored differently? If so, how are they called? http://www.lotpro.com/cars/new/porsche/boxster/ http://www.lotpro.com/search/vehicleinfo/02921/all/all/0/999999/0/999999/5YMGY0C52CLK27716/yy0115/ Thanks Everyone!
  15. Hi Christian, Thanks for the reply but I'm having a little bit of a problem when it comes to your first instruction. Below is my syntax. if (!preg_match('#^\d+$#', $id)) { echo "Missing Data to Run"; //echo $id; } I don't believe I'm doing it correctly because I'm getting this error message everytime I login (below). But here's my problem. After I get this error message and go back to this page (below URL) it's saying I'm logged in? If I had missing data and my header couldn't be modified then how did I login? What am I doing wrong here .... http://whatsmyowncarworth.com/more-practice/member_profile.php?id=10 (Error message when I login) "Missing Data to Run Warning: Cannot modify header information - headers already sent by (output started at whatsmyowncarworth.com/more-practice/member_profile.php:19) in whatsmyowncarworth.com/more-practice/login-from-page.php on line 30" >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> This is all of the php syntax for the member_profile.php page <?php session_start(); // Must start session first thing // See if they are a logged in member by checking Session data $toplinks = ""; if (isset($_SESSION['id'])) { // Put stored session variables into local php variable $userid = $_SESSION['id']; $username = $_SESSION['username']; $toplinks = '<a href="member_profile.php?id=' . $userid . '">' . $username . '</a> • <a href="member_account.php">Account</a> • <a href="logout.php">Log Out</a> • <a>Logged In!</a>'; } else { $toplinks = '<a href="join_form.php">Register</a> • <a href="login.php">Login</a>'; } ?> <?php // Use the URL 'id' variable to set who we want to query info about /* $id = ereg_replace("[^0-9]", "", $_GET['id']); // filter everything but numbers for security if ($id == "") { echo "Missing Data to Run"; exit(); } */ /* if (filter_var($id, FILTER_VALIDATE_INT) == false) { echo "Missing Data to Run"; echo $id; exit(); } */ // $id = $_GET['id'] = 1; // I think this is the correct code to use in replace of what's above but not totally sure yet. ===Figure this out=== It's important. if (!preg_match('#^\d+$#', $id)) { echo "Missing Data to Run"; //echo $id; } //Connect to the database through our include include_once "connect_to_mysql.php"; // Query member data from the database and ready it for display $sql = mysql_query("SELECT * FROM members WHERE id='$id' LIMIT 1"); $count = mysql_num_rows($sql); if ($count > 1) { echo "There is no user with that id here."; exit(); } while($row = mysql_fetch_array($sql)){ $username = $row["username"]; $country = $row["country"]; $state = $row["state"]; $city = $row["city"]; $accounttype = $row["accounttype"]; $bio = $row["bio"]; // Convert the sign up date to be more readable by humans $signupdate = strftime("%b %d, %Y", strtotime($row['signupdate'])); } ?> <?php // this is the login script. It's located on a different page. The member_profile.php includes this file include('login-from-page.php'); ?>
  16. Hi Everyone, Thanks for your responses. Or rather than redirecting all over the place, you can simplify everything by integrating (including) the login code directly on any page that needs it. Yes, this seems a little bit more simplistic (or so I thought). I've been working on this goal for a large portion of the day. I can't quite seem to get things correct. I'm testing this method at the below URL and I'm getting an error of "Missing Data to Run" and I'm not sure why. Any help or suggestions would be great. Below is the URL and also the syntax that's located on the same page. http://whatsmyowncarworth.com/more-practice/member_profile.php?id=10 What do you guys think ... what am I doing wrong here? Thanks everyone! >>>>>>>>>> PHP syntax that's on the above URL <?php session_start(); // Must start session first thing // See if they are a logged in member by checking Session data $toplinks = ""; if (isset($_SESSION['id'])) { // Put stored session variables into local php variable $userid = $_SESSION['id']; $username = $_SESSION['username']; $toplinks = '<a href="member_profile.php?id=' . $userid . '">' . $username . '</a> • <a href="member_account.php">Account</a> • <a href="logout.php">Log Out</a>'; } else { $toplinks = '<a href="join_form.php">Register</a> • <a href="login.php">Login</a>'; } ?> <?php // Use the URL 'id' variable to set who we want to query info about $id = ereg_replace("[^0-9]", "", $_GET['id']); // filter everything but numbers for security if ($id == "") { echo "Missing Data to Run"; exit(); } //Connect to the database through our include include_once "connect_to_mysql.php"; // Query member data from the database and ready it for display $sql = mysql_query("SELECT * FROM members WHERE id='$id' LIMIT 1"); $count = mysql_num_rows($sql); if ($count > 1) { echo "There is no user with that id here."; exit(); } while($row = mysql_fetch_array($sql)){ $username = $row["username"]; $country = $row["country"]; $state = $row["state"]; $city = $row["city"]; $accounttype = $row["accounttype"]; $bio = $row["bio"]; // Convert the sign up date to be more readable by humans $signupdate = strftime("%b %d, %Y", strtotime($row['signupdate'])); } ?> // below is the login script <?php if ($_POST['email']) { //Connect to the database through our include //include_once "connect_to_mysql.php"; $email = stripslashes($_POST['email']); $email = strip_tags($email); $email = mysql_real_escape_string($email); $password = ereg_replace("[^A-Za-z0-9]", "", $_POST['password']); // filter everything but numbers and letters $password = md5($password); // Make query and then register all database data that - // cannot be changed by member into SESSION variables. // Data that you want member to be able to change - // should never be set into a SESSION variable. $sql = mysql_query("SELECT * FROM members WHERE email='$email' AND password='$password' AND emailactivated='1'"); $login_check = mysql_num_rows($sql); if($login_check > 0){ while($row = mysql_fetch_array($sql)){ // Get member ID into a session variable $id = $row["id"]; session_register('id'); $_SESSION['id'] = $id; // Get member username into a session variable $username = $row["username"]; session_register('username'); $_SESSION['username'] = $username; // Update last_log_date field for this member now mysql_query("UPDATE members SET lastlogin=now() WHERE id='$id'"); // Print success message here if all went well then exit the script header("location: member_profile.php?id=$id"); //header("location: http://whatsmyowncarworth.com/more-practice/member_account.php"); exit(); } // close while } else { // Print login failure message to the user and link them back to your login page print '<br /><br /><font color="#FF0000">No match in our records, try again </font><br /> <br /><a href="login.php">Click here</a> to go back to the login page.'; exit(); } }// close if post ?>
  17. Hi, Thanks for the reply. I've found a good example of what I would like to accomplish. In the below URL if you click on "write a review" and are not logged in your automatically diverted to a login page but I noticed in the URL the the park name is being carried to the page. That's what I would like to do. http://nationalrvparks.com/campgrounds-rv-parks/kansas/garden-city/rjs-rv-park In your above statement is that what your talking about? Thanks
  18. Hey Everyone, Thanks for your reply. Appreciate it. I made a little progress today. I added the below syntax and a login URL link is presented. Now I'm trying to figure out after a user logs in how would I get that user back to the car-display-contact-update.php? page? What variables would I need to carry from page to page? How would I get the visitor back to the below page after they login? http://whatsmyowncarworth.com/auto-members/car-display/car-display-contact-update.php?year=57&make=Toyota&model=Camry&submit=Contact+Us This is the syntax I added on my car-display-contact-update.php page if (!isset($_SESSION['id'])) { echo 'Please <a href="http://whatsmyowncarworth.com/auto-members/login.php">log in</a> to access your account'; }
  19. Hi Everyone, I'm a little confused by sessions. This is my goal. In the below URL If someone clicks on "contact us" and they aren't logged in I want that user to be re-directed to a login page. I know I can do this with php sessions but I'm a confused as to how. Does the session have to be on the car-display-contact2.php or the car-display-contact-update.php? or both pages? How would you attack this problem? http://whatsmyowncarworth.com/auto-members/car-display/car-display-contact2.php Thanks everyone!
  20. Hi Everyone, Thanks for the replies and help. I appreciate it. To fix my problem all I needed to do is delete the emailactivated row in my table then insert the same row again. Thanks again everyone! Much appreciated!
  21. Hi Everyone, Thanks for the responses. I tried this and it returned false. This is now the error I'm getting. "ACTIVATION RESULTS Duplicate entry '1' for key 'emailactivated'" http://whatsmyowncarworth.com/more-practice/activation.php?id=9 so I went to my "members" table and looked at the structure of the column of "emailactivated" and this is what I have. Type = enum('0', '1') Collation = utf8_unicode_ci Null = No Default = 0 Any ideas? Thanks again everyone, appreciate the help!
  22. Hi, Thanks for the reply. This is the error message I'm getting. "ACTIVATION RESULTS Your account could not be activated!" http://whatsmyowncarworth.com/more-practice/activation.php?id=9 Yes it does. In this case the email value is 9 (please look at the above URL) In the below URL I have a list of my members (me) and detailed information about each of them and also their activation emails. http://whatsmyowncarworth.com/more-practice/activation.php?id=7 http://whatsmyowncarworth.com/more-practice/activation.php?id=9 http://whatsmyowncarworth.com/more-practice/member-display.php That's been changed. Thanks. The syntax for the join and activation page has stayed the same (for accept the minor change regarding the preg_replace and I also included error reporting on activation page. Below) error_reporting(E_ALL | E_STRICT); ini_set("display_errors", 1); How come it works for one account and not the other ? What am I doing wrong? Thanks!
  23. Hi Everyone, I was testing my script to see if it works. It did for the first registered user (me). I then registered another account using a different email but for some reason my activation page won't activate the account? I'm not sure what's wrong. Below is the syntax for both of the join page and activation. Any help/pointers? http://whatsmyowncarworth.com/more-practice/join_form.php Thanks everyone! activation page <? //Connect to the database through our include include_once "connect_to_mysql.php"; // Get the member id from the URL variable $id = $_REQUEST['id']; $id = ereg_replace("[^0-9]", "", $id); // filter everything but numbers for security if (!$id) { echo "Missing Data to Run"; exit(); } // Update the database field named 'email_activated' to 1 $sql = mysql_query("UPDATE members SET emailactivated='1' WHERE id='$id'"); // Check the database to see if all is right now $sql_doublecheck = mysql_query("SELECT * FROM members WHERE id='$id' AND emailactivated='1'"); $doublecheck = mysql_num_rows($sql_doublecheck); if($doublecheck == 0){ // Print message to the browser saying we could not activate them print "<br /><br /><div align=\"center\"><h3><strong><font color=red>Your account could not be activated!</font></strong><h3><br /></div>"; } elseif ($doublecheck > 0) { // Print a success message to the browser cuz all is good // And supply the user with a link to your log in page, please alter that link line print "<br /><br /><h3><font color=\"#0066CC\"><strong>Your account has been activated!<br /><br /> </strong></font><a href=\"http://whatsmyowncarworth.com/more-practice/login.php\">Click Here</a> to log in now.</h3>"; } ?> >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> join page <?php // Set error message as blank upon arrival to page $errorMsg = ""; // First we check to see if the form has been submitted if (isset($_POST['username'])){ //Connect to the database through our include include_once "connect_to_mysql.php"; // Filter the posted variables $username = ereg_replace("[^A-Za-z0-9]", "", $_POST['username']); // filter everything but numbers and letters $country = ereg_replace("[^A-Z a-z0-9]", "", $_POST['country']); // filter everything but spaces, numbers, and letters $state = ereg_replace("[^A-Z a-z0-9]", "", $_POST['state']); // filter everything but spaces, numbers, and letters $city = ereg_replace("[^A-Z a-z0-9]", "", $_POST['city']); // filter everything but spaces, numbers, and letters $email = stripslashes($_POST['email']); $email = strip_tags($email); $email = mysql_real_escape_string($email); $password = ereg_replace("[^A-Za-z0-9]", "", $_POST['password']); // filter everything but numbers and letters // Check to see if the user filled all fields with // the "Required"(*) symbol next to them in the join form // and print out to them what they have forgotten to put in if((!$username) || (!$country) || (!$state) || (!$city) || (!$email) || (!$password)){ $errorMsg = "You did not submit the following required information!<br /><br />"; if(!$username){ $errorMsg .= "--- User Name"; } else if(!$country){ $errorMsg .= "--- Country"; } else if(!$state){ $errorMsg .= "--- State"; } else if(!$city){ $errorMsg .= "--- City"; } else if(!$email){ $errorMsg .= "--- Email Address"; } else if(!$password){ $errorMsg .= "--- Password"; } } else { // Database duplicate Fields Check $sql_username_check = mysql_query("SELECT id FROM members WHERE username='$username' LIMIT 1"); $sql_email_check = mysql_query("SELECT id FROM members WHERE email='$email' LIMIT 1"); $username_check = mysql_num_rows($sql_username_check); $email_check = mysql_num_rows($sql_email_check); if ($username_check > 0){ $errorMsg = "<u>ERROR:</u><br />Your User Name is already in use inside our system. Please try another."; } else if ($email_check > 0){ $errorMsg = "<u>ERROR:</u><br />Your Email address is already in use inside our system. Please try another."; } else { // Add MD5 Hash to the password variable $hashedPass = md5($password); // Add user info into the database table, claim your fields then values $sql = mysql_query("INSERT INTO members (username, country, state, city, email, password, signupdate) VALUES('$username','$country','$state','$city','$email','$hashedPass', now())") or die (mysql_error()); // Get the inserted ID here to use in the activation email $id = mysql_insert_id(); // Create directory(folder) to hold each user files(pics, MP3s, etc.) mkdir("memberFiles/$id", 0755); // Start assembly of Email Member the activation link $to = "$email"; // Change this to your site admin email $from = "admin@whatsmyowncarworth.com"; $subject = "Complete your registration"; //Begin HTML Email Message where you need to change the activation URL inside $message = '<html> <body bgcolor="#FFFFFF"> Hi ' . $username . ', <br /><br /> You must complete this step to activate your account with us. <br /><br /> Please click here to activate now >> <a href="http://whatsmyowncarworth.com/more-practice/activation.php?id=' . $id . '"> ACTIVATE NOW</a> <br /><br /> Your Login Data is as follows: <br /><br /> E-mail Address: ' . $email . ' <br /> Password: ' . $password . ' <br /><br /> Thanks! </body> </html>'; // end of message $headers = "From: $from\r\n"; $headers .= "Content-type: text/html\r\n"; $to = "$to"; // Finally send the activation email to the member mail($to, $subject, $message, $headers); // Then print a message to the browser for the joiner print "<br /><br /><br /><h4>OK $firstname, one last step to verify your email identity:</h4><br /> We just sent an Activation link to: $email<br /><br /> <strong><font color=\"#990000\">Please check your email inbox in a moment</font></strong> to click on the Activation <br /> Link inside the message. After email activation you can log in."; exit(); // Exit so the form and page does not display, just this success message } // Close else after database duplicate field value checks } // Close else after missing vars check } //Close if $_POST ?> >>>>>>>>>>>>>>>>>>
  24. Hey, I'm getting a parsing error. I've tried a million times to rewrite the code but I don't know what I'm doing wrong. Error is turned on (you can't see that in my above syntax). Thanks!
  25. Hey Christian, Thanks for the code, I appreciate it but I keep on getting an error. It's a simple error but I can't seem to figure it out or where I should delete or move the {. Below is my syntax. What am I doing wrong? Thanks everyone! <?php //Connect to the database through our include include "connect_to_mysql.php"; // Query member data from the database and ready it for display $sql = mysql_query("SELECT price FROM car_data2"); while($row = mysql_fetch_array($sql)){ $price = $row["price"]; } ?> <?php $priceMods = array ('whatever' => 100, 'whatever2' => -100); if (isset ($priceMods[$_POST['choose']]) { $price += $priceMods[$_POST['choose']]; } ?> <html> <head> <title>Untitled Document</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> </head> <body bgcolor="#FFFFFF" text="#000000"> <?php echo "$price"; ?> <form action="math.php" method="post" enctype="multipart/form-data" name="form" id="form" onSubmit="return validate_form ( );"> <table> <tr> <td>Choose:</td> <td> <select name="choose"> <option value="whatever">Whatever</option> <option value="whatever2">Whatever2</option> </select> </td> </tr> <tr> <td width="99"> <input type="submit" name="submit" value="Contact Us"> </td> </tr> </table> </form> </body> </html>
×
×
  • 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.