Jump to content

scm22ri

Members
  • Posts

    89
  • Joined

  • Last visited

Everything posted by scm22ri

  1. Hi Everyone, I have a form on my website where I allow people in insert information. That information will go into my database. My question is, how do I make sure the user/visitor isn't inputting apostrophe's into my database? Below I'm using the ergi_replace function which doesn't seem to work. What else can i do? $variable = stripslashes($variable); $variable = mysql_real_escape_string($variable); $variable = eregi_replace("'", " ", $variable); Thanks
  2. Hi Everyone, How would I go about accounting for a folder in my .htaccess? Meaning this is my domain mydomain.com mydomain.com/products/hot/cakes Should my htaccess code look like this? RewriteRule ^/products/^([_a-zA-Z]+)/([^/]*)$ script.php?product=$1&inventory=$2 [L] maybe this? RewriteRule ^/products/([_a-zA-Z]+)/([^/]*)$ script.php?product=$1&inventory=$2 [L] What am asking is this, how would I go about accounting for the actual folder that I want to put in-front of my URL? Thanks
  3. Thanks requinix, php function trim did the trick!
  4. Hi Everyone, I'm interested in replacing white space after a certain set of characters. The characters aren't a set number, they change depending on what the user types into the form. How would I go about doing that with str_replace? Is it even possible with str_replace or perhaps another function? $value = New York (I don't want to replace the white space between the w and Y but I do want to replace the white space after k if a user uses the space key) $value = str_replace(' ', '', $value); Thanks Everyone
  5. Hi Everyone, I know this question is kinda old but this is what I'm attempting to do. My only concern is when I have a default value 0. The item my user is inputting into the database via a form is automatically displaying on my website. It's my understanding if a item has a default value of 0 shouldn't my MySql database know not to show that item without me approving it first? aka turning the 0 into a 1? The structure of my column. My column is called 'approve' Type ENUM Length/Values '0','1' Default As Defined 0 With a setup like this shouldn't MySql know now to show the items that have a mark of 0?
  6. Hi Everyone, I have a question regarding echoing statements for my website. For some reason my website is echoing out statements that are unrelated to my website. For example, if you visit my website and type in whatever after the /(slash) Google is indexing the term "whatever" A few examples are http://www.mydomain.com/whatver http://www.mydomain.com/advices http://www.mydomain.com/review_ratings http://www.mydomain.com/widgets http://www.mydomain.com/terms_and_conditions http://www.mydomain.com/latest_news http://www.mydomain.com/users/frontend_change_year http://www.mydomain.com/put_whatever_you_want_here_because_google_will_index_it I can go on and on but I think you get the point of what I'm doing. Often times, on my landing page it will say "Latest News", "Whatever", "Review Ratings", "Widgets" etc... In other words, it's echoing out the keyword that's associated with the URL. My question is, how would I go out stopping/fixing this? Thanks Everyone.
  7. Hi PFMaBiSmAd, Thanks for the reply and help. I changed every URL link path to my domain. Some pages I had www, http://, .mydomain.com, / etc ... I changed everything to / and my problem seems to have fixed itself, which I'm happy about. Thanks. This is a little concerning because my phpinfo.php page is still saying session.cookie_domain Local Value > No Value | Master Value > No Value session.cookie_path Local Value > / | Master Value > / It's currently working but the cookie_domain and cookie_path aren't set correctly. Perhaps I'm still doing something wrong? I'm not sure what to make of this. Maybe my mydomain.phpinfo.php page didn't update itself? (although it's been 3-4hrs approx.) Thanks again
  8. Hi Everyone, Thanks for the help. Muddy_Foster, The reason why the session is commented out is because I didn't want to create duplicate pages. It's my understand every time a session is created it creates a unique ID onto that page and the major search engines don't like that. I've also tried this code with the session_start(); on for the inventory page and it still does not work. Perhaps maybe it's this page that's causing the problem? or am I totally wrong when I say that? You should check if the $_SESSION['id'] is actualy set rather than checking if the $user != 0 by using I did just that and it does not seem to be working. I'm testing a few things and changing the syntax around a bit on my get-inventoryphp page. What do you think I'm doing wrong here? Thanks everyone. Below is my syntax for get-inventory.php <?php session_start(); echo 'BEFORE-------------------------------------START><BR>'; print_r($_SESSION); echo 'BEFORE-------------------------------------END><BR>'; include "connect_to_mysql.php"; echo 'AFTER-------------------------------------START><BR>'; print_r($_SESSION); echo 'AFTER-------------------------------------END><BR>'; $_SESSION["pageurls"] = "$url"; $url = $_SERVER["REQUEST_URI"]; $loggedinuser = $_SESSION['id']; $username = $_SESSION["username"]; $carnumber = $_GET["carnumber"]; echo '<!DOCTYPE html> <html> <head> <title>Title goes here</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <meta name="description" content="description goes here" /> <meta name="keywords" content="keywords go here" />'; include 'header.php'; ################################## ## what actually is the $loggedinuser value ## ################################## echo '<BR> '.'>>>>>>>>>'.$loggedinuser.'<<<<<<<<<'.' <BR>'; ################################## ## ## ################################## if(isset($_SESSION['id'])) //checking if user is logged in? { echo "$loggedinuser".'<br>'; echo "$carnumber".'<br>'; echo "Your logged in!"; } else if (!isset($_SESSION['id'])) {//Not logged in echo "User is not logged in show loggin page link <a href=\"loginURL.php?url=$url\">Please login!</a><br>"; } ?> <?php include 'footer.php'; ?>
  9. Hi, I'm trying to figure out why my website isn't displaying a registered user. When I visit a specific page on my website, the page is displaying a message that I'm not logged in but when I visit other pages of my website I'm clearly logged in. My question is, how would I fix this? Right below is the syntax of the php page that's giving me a problem. Below this syntax is syntax of a page a visitor is most likely coming from to visit the "get-inventory.php" page. The "get-inventory.php" I believe is the problem page. get-inventory.php page <?php session_start(); echo 'BEFORE-------------------------------------START><BR>'; print_r($_SESSION); echo 'BEFORE-------------------------------------END><BR>'; // include "connect_to_mysql.php"; echo 'AFTER-------------------------------------START><BR>'; print_r($_SESSION); echo 'AFTER-------------------------------------END><BR>'; include "connect_to_mysql.php"; // $url = $_SERVER['REQUEST_URI']; // $_SESSION['pageurls'] = "$url"; $user = $_SESSION['id']; $car_id = $_GET["car_id"]; include 'header.php'; if ($user !=0){ // notes to myself // include 'header.php'; if I leave out the header.php within the if statement the header does not appear which means I'm def. not logged in. // But my question is why aren't I logged in if I already signed in earlier? // header('Location: http://mywebsite.com/class-work/sign3/valchecklogin.php'); //just redirect the user to thelogin page // header('Location: http://mywebsite.com/loginURL.php?url='.$url.''); echo "$car_id".'<br>'; echo "$user".'<br>'; echo "Your logged in"; // exit(); }else{ echo "$car_id".'<br>'; echo 'Your not logged in'.'<br>'; echo 'click on "Reg" or "Login" and you\'ll see I\'m logged in.'.'<br>'; // exit(); } include 'footer.php'; ?> >>>>> inventory.php page syntax (from this page most visitors will be visiting the above "get-inventory.php" page). I'm not sure if this page is causing the problem but I figured I would add it in here. <?php // session_start(); // $url = $_SERVER['REQUEST_URI']; //Getting Page url and storing in $url variable. // $_SESSION['pageurls']= "$url"; //Now storing that $url variable in SESSION. // $loggedinuser = $_SESSION['id']; include"connect_to_mysql.php"; $state = $_GET["state"]; $city = $_GET["city"]; $year = $_GET["year"]; $make = $_GET["make"]; $model = $_GET["model"]; // for making "pretty" URLS $state = str_replace (' ','_', $state); $city = str_replace (' ','_', $city); $model = str_replace (' ','_', $model); /* $state = str_replace (' ', '', $state); $city = str_replace (' ', '', $city); $make = str_replace (' ', '', $make); $model = str_replace (' ', '', $model); */ /* $state = str_replace (' ', '_', $state ); $city = str_replace (' ', '_', $city ); $year = str_replace (' ', '_', $year ); $make = str_replace (' ', '_', $make ); $model = str_replace (' ', '_', $model ); */ /* $state = str_replace (' ', '_', $state); $city = str_replace (' ', '_', $city); $model = str_replace (' ', '_', $model); */ //////////////// Below is the function function capit($element) { $element = strtolower($element); return ucwords($element); } //////////////// Above is the function $state = capit($state); $city = capit($city); $year = capit($year); $make = capit($make); $model = capit($model); ?> <!DOCTYPE html> <html> <head> <title><?=$year?> <?=$make?> <?=$model?> <?=$city?> <?=$state?></title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <meta name="description" content="<?=$city?> <?=$state?> <?=$year?> <?=$make?> <?=$model?> " /> <meta name="keywords" content="<?=$city?>,<?=$state?>,<?=$year?>,<?=$make?>,<?=$model?> " /> </head> <body bgcolor="#FFFFFF" text="#000000"> <?php include 'header.php'; $sql = mysql_query ("SELECT d.id AS car_id, d.year, d.make, d.model, p.value AS price, p.exterior_color, p.interior_color, p.engine, p.mileage, p.transmission, p.gas_type, p.state, p.city FROM tbl_car_description d, tbl_car_prices p WHERE (d.id = p.cardescription_id) AND (p.state = '".$state."') AND (p.city = '".$city."') AND (d.year = '".$year."') AND (d.make = '".$make."') AND (d.model = '".$model."')"); while($row = mysql_fetch_array($sql)){ $car_id = $row["car_id"]; $year = $row["year"]; $make = $row["make"]; $model = $row["model"]; $price= $row["price"]; $exteriorcolor = $row["exterior_color"]; $interiorcolor = $row["interior_color"]; $engine = $row["engine"]; $mileage = $row["mileage"]; $transmission = $row["transmission"]; $gastype = $row["gas_type"]; $state = $row["state"]; $city = $row["city"]; echo "$car_id".'<br>'; echo "$year".'<br>'; echo "$make".'<br>'; echo "$model".'<br>'; echo "$price".'<br>'; echo "$exteriorcolor".'<br>'; echo "$interiorcolor".'<br>'; echo "$engine".'<br>'; echo "$mileage".'<br>'; echo "$transmission".'<br>'; echo "$gastype".'<br>'; echo "$state".'<br>'; echo "$city".'<br>'; echo "<a href ='http://www.mywebsite.com/get-car3.php?car_id=$car_id'>Sell this car!</a>".'<br>'; } echo "The below URL link is hardcoded".'<br>'; echo "<a href ='http://www.mywebsite.com/get-car3.php?car_id=6'>-Sell this car!</a>".'<br>'; ?> <?php include 'footer.php' ?>
  10. Hi Everyone, I'm trying to figure out how to have a dash or hyphen in between two words in my URL. I did this correctly in my longer URLS but for some reason I can't figure out what I'm doing wrong when it comes to my shorter URLS. To better explain, I've listed my examples below. Any help would be appreciated. Thanks URL words but no data is showing. http://whatsmyowncarworth.com/new-york Working http://whatsmyowncarworth.com/massachusetts // notice the - in between "cape code". I can't get that same -(dask aka hyphen) for new-york or rhode-island http://whatsmyowncarworth.com/massachusetts/cape-cod http://whatsmyowncarworth.com/vehicle-display.php What am I doing wrong here? RewriteEngine On RewriteRule ^([-a-zA-Z-]+)$ state.php?state=$1 [L] RewriteRule ^([-a-zA-Z-]+)/([-a-zA-Z-]+)$ city-breakdown.php?state=$1&city=$2 [L]
  11. Hey Guys, Thanks a lot for helping me out with .htaccess. It's working but for some reason my CSS isn't working? It seems the city pages aren't displaying properly. I'm not sure what the problem is, could it even be my CSS? or perhaps it's my .htaccess? What do you guys think? (state page is fine) http://whatsmyowncarworth.com/rhode_island (city pages aren't displaying my CSS) http://whatsmyowncarworth.com/rhode_island/cranston http://whatsmyowncarworth.com/rhode_island/cumberland http://whatsmyowncarworth.com/rhode_island/east_providence http://whatsmyowncarworth.com/rhode_island/east_greenwhich http://whatsmyowncarworth.com/rhode_island/exeter
  12. Hey Marcus, Thanks for the help. I did what you said and the URL links work now but the data isn't showing up on my website. Could this be because of the htaccess file? http://whatsmyowncar...om/rhode-island http://whatsmyowncarworth.com/new-york RewriteEngine On RewriteRule ^([-a-zA-Z_]+)$ state.php?state=$1 [L] RewriteRule ^([a-zA-Z_]+)/([a-zA-Z_]+)$ city-breakdown.php?state=$1&city=$2 [L]
  13. Hi, I have a question regarding .htaccess. I'm attempting to make pretty URLS. I'm almost half way there but I can't quite seem to figure how to add a "dash" - to certain keywords. On the below page http://whatsmyowncar...cle-display.php How would I turn http://whatsmyowncar...th.com/new york into http://whatsmyowncarworth.com/new-york Below is my .htaccess file. Any help would be appreciated. Thanks. RewriteEngine On RewriteRule ^([a-zA-Z_]+)$ state.php?state=$1 [L]
  14. Hi Everyone, I've figured out how to re write a url correctly to my website. The problem is no content is showing on the page. I want to take the below URL http://whatsmyowncar...te=rhode island and turn it into this one (I think I've accomplish that but on the below URL, the page is showing no data). I figred my .htacess was a bit off but I'm not sure how. What am I doing wrong here? http://whatsmyowncar...om/rhode-island RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^([^/]*)$ /state.php?s=&u=$1 [L,NC]
  15. Hi Everyone, I'm trying to figure out the correct syntax when it comes to displaying an image on my website. When I hard code the number in it works but when I add the variable $id it's not working. // Not working echo '<div align="center"><img src="photos'. $id . rand(1,3) . '.jpg" width="250" alt="Random Image" /></div></td>'; echo '<div align="center"><img src="photos'. $id .''. rand(1,3) . '.jpg" width="250" alt="Random Image"/></div></td>'; echo '<div align="center"><img src="photos'.$id. rand(1,3) . '.jpg" width="250" alt="Random Image" /></div></td>'; echo '<div align="center"><img src="photos/'.$id.'/'.echo rand(1,n);'.jpg" width="250" /></div></td>'; echo '<div align="center"><img src="photos/'. $id . rand(1,3) . '.jpg" width="250" alt="Random Image" /></div></td>'; //Works but only when I hard code the number 4 (but I can't have that because every photo is in a different folder. echo '<div align="center"><img src="photos'. '/4/' . rand(1,3) . '.jpg" width="250" alt="Random Image" /></div></td>'; Any help would be appreciated, thanks! Hey Everyone, I finally solved the problem. The correct syntax is echo '<div align="center"><img src="photos/'. $id .'/'. rand(1,3) . '.jpg" width="250" alt="Random Image"/></div></td>';
  16. Hi Everyone, I'm trying to echo out an image in a while loop but my syntax is wrong. What am I doing wrong? echo '<div align="center"><img src="photos/<?php echo rand(1,n);?>.jpg" alt="Random Image" /></div></td>'; Thanks!
  17. Hi Everyone, How would I go about joining 3 tables at once? My database design/setup is at the below URL. I want the mysql statement to say "1992 Ford Explorer" http://whatsmyowncarworth.com/class-work/sign3/database/database-display.php Thanks Everyone!
  18. Thanks Adam, I went about this in a slightly different manner. What do you think about my answer? I did in fact use a switch statement. I requested the url as a unique identifier of each page. According to the url it's going to return a specific statement. <?php $title; $url = $_SERVER['REQUEST_URI']; switch($url){ case "/class-work/sign3/valchecklogin.php"; $title = 'Home'; break; case "/class-work/sign3/heythere.php"; $title = 'Profile Page'; break; case "/class-work/sign3/display-inventory.php"; $title = 'Inventory Page'; break; case "/class-work/sign3/mygoal.php"; $title = 'My Goal'; break; case "/class-work/sign3/add-car.php"; $title = 'Add Car'; break; case "/class-work/sign3/add-dealership.php"; $title = 'Add Cardealership'; break; case "/class-work/sign3/edit-car.php"; $title = 'Edit Cars'; break; case "/class-work/sign3/cal.php"; $title = 'Calculator'; break; // the results page poses a issue. Not quite sure how to fix this? case "/class-work/sign3/cal-results.php?"; $title = 'Calculator Results'; break; case "/class-work/sign3/forgot2.php"; $title = 'Forgot Password'; break; case "/class-work/sign3/change-password.php"; $title = 'Change Password'; break; case "/class-work/sign3/register.php"; $title = 'Register'; break; case "/class-work/sign3/contact.php"; $title = 'Contact Us'; break; case "/class-work/sign3/logout.php"; $title = 'Logout'; break; } ?>
  19. Hi Everyone, How would I dynamically change meta tag information on a per page basis? If a visit is on my "about" or "inventory" page. In the title and meta tag I would want that user to see "about us" or "inventory". I've written some below sample code but it's not working. Not sure what I'm doing. For example, this page should be echoing out "Title Test Page" but it's not. What am I doing wrong here? Thanks! http://whatsmyowncar...3/titletest.php <?php $title; switch($_SERVER['PHP_SELF']) { case "/index.php": $title = 'Home'; break; case "/titletest.php": $title = 'Title Test Page'; break; } print '<title>'.$title.'</title>'; ?>
  20. Hi Everyone, Thanks for your responses. The reason why I have to query the database twice is because I get this error if I don't I'm going to take this from the top. This url link is the function I'm using. (syntax for function) http://whatsmyowncarworth.com/class-work/sign3/edit-car-function-for-login2.php It's echoing out information so it must be working. Below is my entire code on my login page. I'm including the function but it's not working. Gizmola, you said the function had to return something. In this case, would it return a $username and $password? in order for it to work? <?php session_start(); include"connect_to_mysql3.php"; $loggedinuser = $_SESSION["id"]; $name = $_SESSION["name"]; include 'edit-car-function-for-login2.php'; /* if (isset( $_POST['name'], $_POST['password'] )){ $name = $_POST['name']; $password = $_POST['password']; $password = sha1($password); $name = mysql_real_escape_string($name); $password = mysql_real_escape_string($password); $sql_id = mysql_query("SELECT * FROM practice WHERE name='$name' AND password='$password'"); while($row = mysql_fetch_array($sql_id)){ $id = $row["id"]; } $sql = ("SELECT id FROM practice WHERE name='$name' AND password='$password'"); $result = mysql_query($sql); $count=mysql_num_rows($result); if($count==1){ $_SESSION["name"] = $name; $_SESSION["id"] = $id; header("location:heythere.php"); } else { echo "Wrong Username and Password."; } } */ ?> <?php include 'header.php'; ?> <?php if ($loggedinuser == true){ echo "Hi $name, your logged in! <br>"; echo "<p><a href=\"http://whatsmyowncarworth.com/class-work/sign3/logout.php\">Log Out</a></p>"; } else { echo '<table width="300" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC"> <tr> <form name="form1" method="post" action="valchecklogin.php"> <td> <table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF"> <tr> <td colspan="3"><strong>Member Login </strong></td> </tr> <tr> <td width="78">Username</td> <td width="6">:</td> <td width="294"><input name="name" type="text" id="name"></td> </tr> <tr> <td>Password</td> <td>:</td> <td><input name="password" type="text" id="password"></td> </tr> <tr> <td> </td> <td> </td> <td><input type="submit" name="Submit" value="Login"></td> </tr> </table> </td> </form> </tr> </table>'; } ?> <?php include 'footer.php'; ?>
  21. Hi Everyone, I wrote a function for a login script. I tested the function and it's working but when I include it on my website it's not working. I'm not sure what I'm doing wrong. What do you guys think? Thanks Everyone. syntax for function function loggeduser($name, $password){ $name = mysql_real_escape_string($name); $password = mysql_real_escape_string($password); $password = sha1($password); // getting the ID here $sql_id = mysql_query("SELECT * FROM practice WHERE name='$name' AND password='$password'"); while($row = mysql_fetch_array($sql_id)){ $id = $row["id"]; } $sql = ("SELECT id FROM practice WHERE name='$name' AND password='$password'"); $result = mysql_query($sql) or die(mysql_error()); $count= mysql_num_rows($result); if ($count == 1){ $_SESSION['authorized'] = true; $_SESSION['id']; // <-- not sure if I need this? $_SESSION['password'] = $password; $_SESSION['name'] = $name; header("location:userspage.php"); } else { echo "Wrong username and password <br>"; } } login script <?php session_start(); include"connect_to_mysql3.php"; $loggedinuser = $_SESSION["id"]; $name = $_SESSION["name"]; // include 'edit-car-function-for-login.php'; if (isset( $_POST['name'], $_POST['password'] )){ $name = $_POST['name']; $password = $_POST['password']; $password = sha1($password); $name = mysql_real_escape_string($name); $password = mysql_real_escape_string($password); $sql_id = mysql_query("SELECT * FROM practice WHERE name='$name' AND password='$password'"); while($row = mysql_fetch_array($sql_id)){ $id = $row["id"]; } $sql = ("SELECT id FROM practice WHERE name='$name' AND password='$password'"); $result = mysql_query($sql); $count=mysql_num_rows($result); if($count==1){ $_SESSION["name"] = $name; $_SESSION["id"] = $id; header("location:userspage.php"); } else { echo "Wrong Username and Password."; } }
  22. Hi Everyone, If a user presses "submit" and does not fill in any information into the text fields they are suppose to get a error message stating "All fields Required" but if you press "submit" it says I'm not sure what I'm doing wrong here. Any ideas? http://whatsmyowncar...ship-submit.php <?php include "connect_to_mysql3.php"; //////////////// Below is the function function capitalize($element) { $element = strtolower($element); return ucwords($element); } //////////////// Above is the function if (isset ( $_POST['dealership'] ) ){ $dealership = $_POST['dealership']; $address = $_POST['address']; $state = $_POST['state']; $city = $_POST['city']; $zip = $_POST['zip']; $phone = $_POST['phone']; $website = $_POST['website']; $email = $_POST['email']; $name = $_POST['name']; $dealership = mysql_real_escape_string($dealership); $address = mysql_real_escape_string($address); $state = mysql_real_escape_string($state); $city = mysql_real_escape_string($city); $zip = mysql_real_escape_string($zip); $phone = mysql_real_escape_string($phone); $website = mysql_real_escape_string($website); $email = mysql_real_escape_string($email); $name = mysql_real_escape_string($name); $dealership = capitalize($dealership); $state = capitalize($state); $city = capitalize($city); $name = capitalize($name); if ( empty($dealership) || empty($address) || empty($state) || empty($city) || empty($zip) || empty($phone) || empty($website) || empty($email) || empty($name) ){ $errors[] = "All Fields Are Required! <br>"; } else { if (strlen($dealership) > 65){ $errors[] = 'Dealership name is too long. Shorten it'.'<br>'; } if (strlen($state) > 65){ $errors[] = 'State name too long. Shorten it'.'<br>'; } if (!is_numeric($zip)){ $errors[] = 'Please enter a valid zip.'.'<br>'; } if(strlen($zip) > 6 || strlen($zip) == 6){ // If string/pass length is greater then 6 or equal to 6 it will display password okay, // You can do further code here, else, It will show short pass error. // echo"Its good mate! have atleast 5 digit pass "; // You can continue your login code here... } else{ $errors[] = 'Please enter a valid zip code'.'<br>'; } if (filter_var($email, FILTER_VALIDATE_EMAIL) === FALSE){ $errors[] = 'Please enter a valid email.'.'<br>'; } } if(!empty($errors)){ foreach ($errors as $error){ echo "$error"; } } else { $insert = ("INSERT INTO dealers (name, state, city, age, email, password, time) VALUES ('$name','$state','$city','$age','$email','$password', now() )"); mysql_query($insert); /* $to = $email; $from = "admin@whatsmyowncarworth.com"; $subject = "Thanks for signing up!"; $message = '<html> <body bgcolor="#FFFFFF"> Hi ' . $name . ', <br /><br /> Thanks for signing up! <br /><br /> <a href="http://www.yahoo.com?city='. $city .'" target="_blank">Browse through cars in your city!</a> </a> <br /><br /> Thanks! </body> </html>'; $headers = "From: $from\r\n"; $headers .= "Content-type: text/html\r\n"; $to = "$to"; mail($to, $subject, $message, $headers); echo 'Thanks for submitting your information.'; */ } } ?> <form action="add-dealership-submit.php" method="POST"> <table> <tr> <td width="99">Dealership Name:</td> <td width="112"> <input type="text" name="dealership" value="<?php $dealership ;?> " /> </td> </tr> <tr> <td width="99">Address:</td> <td width="112"> <input type="text" name="address" value="<?php $address ;?> " /> </td> </tr> <tr> <td width="99">State:</td> <td width="112"> <input type="text" name="state" value="<?php $state ;?> " /> </td> </tr> <tr> <td width="99">City:</td> <td width="112"> <input type="text" name="city" value="<?php $city ;?> " /> </td> </tr> <tr> <td width="99">Zip:</td> <td width="112"> <input type="text" name="zip" value="<?php $zip ;?> " /> </td> </tr> <tr> <td width="99">Phone:</td> <td width="112"> <input type="text" name="phone" value="<?php $phone ;?> " /> </td> </tr> <tr> <td width="99">Website:</td> <td width="112"> <input type="text" name="website" value="<?php $website ;?> " /> </td> </tr> <tr> <td width="99">Email:</td> <td width="112"> <input type="text" name="email" value="<?php $email ;?> " /> </td> </tr> <tr> <td width="99">Your Name:</td> <td width="112"> <input type="text" name="name" value="<?php $name ;?> " /> </td> </tr> <tr> <td width="99"> <input type="submit" name="submit" value="Submit"> </td> </tr> </table> </form>
  23. Hi Everyone, I've partly figured out how to change my URLs but I'm having trouble with fixing the space(%20) that's located in my URL. I've tried using the str_replace function but it's either not working or I'm not doing in correctly. My goal is to turn this URL (first one below this statement) into the URL that's below the first one. I'm having a hard time figuring this out. Any help would be appreciated. Thanks Everyone! (URL that works but it has %20, which is something I don't want) http://whatsmyowncar...lorida/key west (URL that does not work but I'm attemping to make the above URL look like this one) http://whatsmyowncar...lorida/key-west My .htaccess code is below as well. Thanks again 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'])); $city = str_replace('%20','-',urldecode($_GET['u'])); // $city = str_replace('','-',urldecode($_GET['u'])); // $city = str_replace('-','','%20','-', 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"]; } } } } ?> RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^([^/]+)/(.*) /auto/cars.php?s=$1&u=$2 [L,NC]
  24. Hi Everyone, I have a question regarding validating my form when a user inputs information. For "city" if a user inputs 333 or 23223 or any other type of number you'll get the error message "Your city must be valid". I just want to know if I'm going about the correct method for form validation? My goal is to make sure the user is non numerical data into the city field. I think I might be doing it correctly. What do you guys think? Thanks! <?php if (isset ( $_POST['name'], $_POST['name2'], $_POST['state'], $_POST['city'], $_POST['age'], $_POST['email'], $_POST['password'], $_POST['password2'] ) ){ $name = $_POST['name']; $name2 = $_POST['name2']; $state = $_POST['state']; $city = $_POST['city']; $age = $_POST['age']; $email = $_POST['email']; $password = $_POST['password']; $password2 = $_POST['password2']; // || empty($state) || empty($city) // how would I make sure a person that's inserting a city, enters a actual city and not a number? if ( empty($name) || empty($name2) || empty($age) || empty($city) || empty($email) || empty($password) || empty($password2) ){ // $name33 = "Fill in Name"; $errors[] = "All Fields Are Required! <br>"; } else { if (strlen($name AND $name2) > 25){ $errors[] = 'Name is too long. Shorten it'.'<br>'; } if ($name != $name2){ $errors[] = 'Names don\'t match. Write matching names!'.'<br>'; } if (is_numeric($city)){ $errors[] = 'Your city must be valid!'; } if (!is_numeric($age)){ $errors[] = 'Please enter a valid age.'.'<br>'; } else if ($age <=0){ $errors[] = 'Please enter a valid age.'.'<br>'; } if (filter_var($email, FILTER_VALIDATE_EMAIL) === FALSE){ $errors[] = 'Please enter a valid email.'.'<br>'; } if ($password != $password2){ $errors[] = 'Your passwords don\'t match'.'<br>'; } } // print_r ($errors); // echo "$whatever"; // echo "$name33"; if(!empty($errors)){ foreach ($errors as $error){ echo "$error"; } } else { echo "Register User!"; } } ?>
  25. Thanks again Christian. I know my code has a lot of bugs but as I get better at coding I'm sure they'll disappear. Christian, regarding the sessions when I comment out // the session_register() and use $_SESSION['mypassword']; and $_SESSION['myusername']; it's not allowing me to login. I'm not sure why it's doing that. Any pointers? Thanks!
×
×
  • 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.