
Dada78
Members-
Posts
358 -
Joined
-
Last visited
Never
Everything posted by Dada78
-
I get nothing, it just shows a blank white page when I hit submit.
-
I got this error Warning: move_uploaded_file(/home/mesquit1/public_html/local/submitted/73var/tmp/phpcAvMv2) [function.move-uploaded-file]: failed to open stream: No such file or directory in /home/mesquit1/public_html/local/submit.php on line 49 Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move '/var/tmp/phpcAvMv2' to '/home/mesquit1/public_html/local/submitted/73var/tmp/phpcAvMv2' in /home/mesquit1/public_html/local/submit.php on line 49 Failed to upload file to /home/mesquit1/public_html/local/submitted/73var/tmp/phpcAvMv2 Line 49 is this line. if(!move_uploaded_file($_FILES['imgdata']['tmp_name'], $image_dir.$filename)) Here is the entire code. <?php $image_dir = dirname(__FILE__).'/submitted/'; if(!is_dir($image_dir)) die("Image dir does not exist"); if(!is_writable($image_dir)) die("Image dir is not writable"); // here, we check if the form has been submitted, because we need to handle // redirection before we handle outputting the HTML stuff. if(isset($_POST['submit'])){ if(empty($_POST['displayname'])) $error = '*Please fill in displayname field.'; elseif(empty($_POST['displaytype'])) $error = '*Please fill in displaytype field.'; elseif(empty($_POST['description'])) $error = '*Please fill in description field.'; elseif(empty($_POST['address'])) $error = '*Please fill in address field.'; elseif(empty($_POST['city'])) $error = '*Please fill in city field.'; elseif(empty($_POST['state'])) $error = '*Please fill in state field.'; elseif(empty($_POST['postal'])) $error = '*Please fill in postal field.'; elseif(empty($_POST['country'])) $error = '*Please fill in country field.'; elseif(!is_uploaded_file($_FILES['imgdata']['tmp_name'])) $error = '*Please upload a picture.'; else{ // MAKE CONNECTION include ('db_connect.php'); $displayname = mysql_real_escape_string($_POST['displayname']); $displaytype = mysql_real_escape_string($_POST['displaytype']); $description = mysql_real_escape_string($_POST['description']); $address = mysql_real_escape_string($_POST['address']); $address2 = mysql_real_escape_string($_POST['address2']); $city = mysql_real_escape_string($_POST['city']); $state = mysql_real_escape_string($_POST['state']); $postal = mysql_real_escape_string($_POST['postal']); $country = mysql_real_escape_string($_POST['country']); $website = mysql_real_escape_string($_POST['website']); //Add user mysql_query("INSERT INTO users (displayname, displaytype, description, address, address2, city, state, postal, country, website) VALUES ('$displayname', '$displaytype', '$description', '$address', '$address2', '$city', '$state', '$postal', '$country', '$website')")or die (mysql_error()); //Move image $userid = mysql_insert_id(); $ext = substr($_FILES['imgdata']['tmp_name'], strrpos($_FILES['imgdata']['tmp_name'], '.') + 1); $filename = $userid.$ext; if(!move_uploaded_file($_FILES['imgdata']['tmp_name'], $image_dir.$filename)) die("Failed to upload file to ".$image_dir.$filename); } //Add filename to DB mysql_query("UPDATE users SET imgurl = '".mysql_real_escape_string($filename)."' WHERE id = '$userid'"); } ?>[\code] -Thanks
-
Failed to upload file to /home/mesquit1/public_html/local/submitted/70
-
Ok tried this. $image_dir = dirname(__FILE__).'/submitted/'; if(!is_dir($image_dir)) die("Image dir does not exist"); if(!is_writable($image_dir)) die("Image dir is not writable"); I am not getting the Image dir error anymore, but I am getting "Failed to upload file" error
-
Ok I have tried it like this. $image_dir = '/public_html/local/submitted/'; and like suggested above like this $image_dir = dirname(__FILE__).'/local/submitted/'; And I am still getting "Image dir does not exist". What am I missing?
-
Ok it is saying Image dir does not exist But it does exist because these pictures are in that folder http://www.mesquitechristmas.com/local/submitted/0003.JPG This is how I have it set $image_dir = '/local/submitted/'; Any idea what I am doing wrong? -Thanks
-
I want to thank you for your help first off. Ok I have tired this and I when I submit the form I get this error Failed to upload file Is their something I need to set for this first? Also I am curious, what does mysql_real_escape_string do? <?php $image_dir = '/local/submitted/'; // here, we check if the form has been submitted, because we need to handle // redirection before we handle outputting the HTML stuff. if(isset($_POST['submit'])){ if(empty($_POST['displayname'])) $error = '*Please fill in displayname field.'; elseif(empty($_POST['displaytype'])) $error = '*Please fill in displaytype field.'; elseif(empty($_POST['description'])) $error = '*Please fill in description field.'; elseif(empty($_POST['address'])) $error = '*Please fill in address field.'; elseif(empty($_POST['city'])) $error = '*Please fill in city field.'; elseif(empty($_POST['state'])) $error = '*Please fill in state field.'; elseif(empty($_POST['postal'])) $error = '*Please fill in postal field.'; elseif(empty($_POST['country'])) $error = '*Please fill in country field.'; elseif(!is_uploaded_file($_FILES['imgdata']['tmp_name'])) $error = '*Please upload a picture.'; else{ // MAKE CONNECTION include ('db_connect.php'); $displayname = mysql_real_escape_string($_POST['displayname']); $displaytype = mysql_real_escape_string($_POST['displaytype']); $description = mysql_real_escape_string($_POST['description']); $address = mysql_real_escape_string($_POST['address']); $address2 = mysql_real_escape_string($_POST['address2']); $city = mysql_real_escape_string($_POST['city']); $state = mysql_real_escape_string($_POST['state']); $postal = mysql_real_escape_string($_POST['postal']); $country = mysql_real_escape_string($_POST['country']); $website = mysql_real_escape_string($_POST['website']); //Add user mysql_query("INSERT INTO users (displayname, displaytype, description, address, address2, city, state, postal, country, website) VALUES ('$displayname', '$displaytype', '$description', '$address', '$address2', '$city', '$state', '$postal', '$country', '$website')")or die (mysql_error()); //Move image $userid = mysql_insert_id(); $ext = substr($_FILES['userfile']['tmp_name'], strrpos($_FILES['userfile']['tmp_name'], '.') + 1); $filename = $userid.$ext; if(!move_uploaded_file($_FILES['userfile']['tmp_name'], $image_dir.$filename)) die("Failed to upload file"); } //Add filename to DB mysql_query("UPDATE users SET imgurl = '".mysql_real_escape_string($filename)."' WHERE id = '$userid'"); } ?> -Thanks
-
The field name is "imgurl" the text field name is listed in the code in the first post. That is what I planned to do and wanted to do. The unique identifier is id.
-
Can anyone help me with what I AM wanting to do? All I need is help with uploading a file to a folder on my server and storing the base path in the database which I already have created. Anyone know how to do this or point me where I can learn how to do this? -Thanks
-
Can anyone help me with what I AM wanting to do? All I need is help with uploading a file to a folder on my server and storing the base path in the database which I already have created. Anyone know how to do this or point me where I can learn how to do this? -Thanks
-
That won't work because I need the image base path to be on the same row with the rest of the users display information, not in another table. Naming won't be an issue because you can set the image name when it is uploaded where each one will be different. Reason being if the users display information is id100 and the image is id2 you are going to have a hard time getting the right image to the right display. Can anyone help me with what I AM wanting to do? All I need is help with uploading a file to a folder on my server and storing the base path in the database which I already have created. Anyone know how to do this or point me where I can learn how to do this? -Thanks
-
Because it saves space in the database from having huge files stored in the database when you can store the actual images on the server then store the URL to the image so you can call it later where you need it with a simple echo statement. For example the pictures on this page uses this method. http://www.mesquitechristmas.com/local/browse.php They are being called from the database with a stored URL. So for example the file is uploaded to file on the server then the URL is stored in a field in the table like this /local/submitted/0003.JPG Then with a simple echo I can display the image like shown on those pages and not waste space and drain MySQL resrouces. Those pictures I have manually inserted so I can test but now I need a way to upload these to the server then store the URL like above in the DB so I can call the pictures where I need them. Please don't question the way I want to do something unless you want to build something better for me that won't drain MySQL resources. Otherwise if you know how I can do what I am needing done then I am open to learn. -Thanks
-
I have a simple submission form where everything works on it. I just need one last thing to add and get working The form is below http://www.mesquitechristmas.com/local/submit.php I need to be able upload a file to my server and then store the url to that image in table in my DB. I already have the folder and field in the table set up. So if anyone can tell me or show me how I can integrate this into the form I have now that would be great. The current code to the file is below. <?php // here, we check if the form has been submitted, because we need to handle // redirection before we handle outputting the HTML stuff. if(isset($_POST['submit'])) { if(empty($_POST['displayname'])) $error = '*Please fill in displayname field.'; elseif(empty($_POST['displaytype'])) $error = '*Please fill in displaytype field.'; elseif(empty($_POST['description'])) $error = '*Please fill in description field.'; elseif(empty($_POST['address'])) $error = '*Please fill in address field.'; elseif(empty($_POST['city'])) $error = '*Please fill in city field.'; elseif(empty($_POST['state'])) $error = '*Please fill in state field.'; elseif(empty($_POST['postal'])) $error = '*Please fill in postal field.'; elseif(empty($_POST['country'])) $error = '*Please fill in country field.'; else { // MAKE CONNECTION include ('db_connect.php'); $displayname = $_POST['displayname']; $displaytype = $_POST['displaytype']; $description = $_POST['description']; $address = $_POST['address']; $address2 = $_POST['address2']; $city = $_POST['city']; $state = $_POST['state']; $postal = $_POST['postal']; $country = $_POST['country']; $website = $_POST['website']; $imgdata = file_get_contents($_FILES['imgdata']['tmp_name']); mysql_query("INSERT INTO users (displayname, displaytype, description, address, address2, city, state, postal, country, website) VALUES ('$displayname', '$displaytype', '$description', '$address', '$address2', '$city', '$state', '$postal', '$country', '$website')")or die (mysql_error()); } } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <meta name="description" content="Mesquite Texas Country Christmas" /> <meta name="keywords" content="Mesquite, Texas, Country Christmas" /> <meta name="author" content="NA" /> <link rel="stylesheet" type="text/css" href="/stylesheet.css" media="screen" title="FBC" /> <script type="text/javascript" src="drop_down.js"></script> <title>A Mesquite Country Christmas - Display Submission</title> </head> <body> <div id="wrap"> <a href="/index.html"> <img id="frontphoto" src="/images/header.png" width="760" height="237" alt="Mesquite Country Christmas" border="0"></a> <div id="menu"> <h2 class="hide">Menu:</h2> <ul id="avmenu"> <li><a href="/index.html">Home</a></li> <li><a href="/christmasstory.html">The Christmas Story</a></li> <li><a href="/directions.html">Directions</a></li> <li><a href="#">Information</a><ul> <li><a href="/information.html">Display Facts & Info</a></li> <li><a href="/faq.html">FAQ</a></li> <li><a href="/playlist.html">2008 Playlist</a></li> <li><a href="#">Christmas History</a></li> </ul></li> <li><a href="#">Photos</a> <ul> <li><a href="/2007photos.html">2007</a></li> </ul></li> <li><a href="#">Videos</a> <ul> <li><a href="/2007videos.html">2007</a></li> </ul></li> <li><a href="/guestbook.php">Guestbook</a></li> <li><a href="/webcam.html">Web Cam</a></li> <li><a href="/webradio.html">Internet Radio</a></li> <li><a href="http://www.noradsanta.org/" TARGET="_blank">Track Santa</a></li> <li><a href="/projects.html">Projects & How Tos</a></li> <li><a href="/links.html">Links</a></li> <li><a href="/contact_us.html">Contact Us</a></li> </ul> <center><a href="http://www.toysfortots.org/" TARGET="_blank"><img src="/images/toys_for_tots.jpg" border="0" width="110" height="153" vspace="10"></a></center> <center><a href="http://christmas.bronners.com/2007/house/534.html"><img src="http://christmas.bronners.com/voteforme/vote.jpg" border="0" width="110" height="153" alt="christmas decorations" vspace="10"></a></center> </div> <div id="content"> <div class="fadebox"> <h2> Submit your Lights</h2> <hr /> <p><img src="/images/christmas-lights.jpg" width="153" height="208" alt="Submit Lights" align="left" border="0" hspace="10"> Thank you for submitting your home to the Mesquites Country Christmas display finder database. There are some things you should know before submitting to make your experience a pleasant one.</p><p>First of all, we do not release your personal information to anyone for any reason. The only exception to this, obviously, is the address of the display, the website (if it has one), and a picture of the display.</p><p>Secondly, please have a picture available to use for your display. You won't be able to submit your display without one. When submitting a picture, please make sure that the file is less than one megabyte (1 Meg or 1024k), and if possible, resize it to 640x480. Please also be sure your picture is in JPG format.</p><p>Your display will not immediately be entered into the Christmas Light Finder database. We will first have to approve your submission. This is so that those unscrupulous folks out there can't submit unacceptable pictures (not family friendly). Please allow up to 48 hours to be included into the database, though, the time before insertion is usually much shorter than that.</p> </div> <div class="fadebox"> <h2> Ready to submit? Fill out the form below:</h2> <hr /> <br /> <form enctype="multipart/form-data" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> <table> <tr> <td>Display Name*</td><td><input name="displayname" value="<?php echo $displayname; ?>" size="40" type="text"></td></tr> <tr> <td>Display Type*</td><td><select name="displaytype"><option value="Residential">Residential</option><option value="Neighborhood">Neighborhood</option><option value="Commercial">Commercial</option><option value="City/Government">City/Government</option><option value="Sponsored">Sponsored</option></select></td></tr> <tr><td>Description*</td><td><textarea name="description" cols="30" rows="5"><?php echo $description; ?></textarea></td></tr> <tr><td>Address*</td><td><input name="address" value="<?php echo $address; ?>" size="40" type="text"></td></tr><tr><td>Address 2</td><td><input name="address2" size="40" type="text"></td></tr> <tr><td>City*</td><td><input name="city" size="30" type="text" value="Mesquite"></td></tr> <tr><td>State/Province*</td><td><input name="state" size="30" type="text" value="Texas"></td></tr> <tr><td>Postal Code*</td><td><select name="postal"><option value="75149">75149</option><option value="75150">75150</option><option value="75180">75180</option><option value="75181">75181</option><option value="75185">75185</option><option value="75187">75187</option></select></td></tr> <tr><td>Country*</td><td><input name="country" size="30" type="text" value="United States"></td></tr> <tr><td>Website</td><td><input name="website" size="50" value="http://<?php echo $website; ?>" type="text"></td></tr> <tr><td>Picture*</td><td><input type="file" name="imgdata" size="35"></td></tr> <tr> <td colspan="2" align="right" class="errorText"> <?PHP // then we check for the error message if (isset($error)) { echo $error . '<br />'; } ?> </td> </tr> <tr><td colspan="2" style="border-top: 1px solid black;" align="right"> <br /> <input name="submit" value="Submit Now" type="submit"></td></tr> </tbody></table></form> <br>* Fields are required. <br> </div> </div> <div id="footer"> © 2007 Mesquite Country Christmas <br /> <br /> <script type="text/javascript"><!-- google_ad_client = "pub-8048181801684156"; //468x60, created 1/8/08 google_ad_slot = "0360766123"; google_ad_width = 468; google_ad_height = 60; //--></script> <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script> </div> </div> </body> </html> -Thanks in Advance
-
Ok gotcha, that works great now and everything is perfect, Thank you for all your help.
-
I am not sure I follow you. I already have that, look in the last code I posted.
-
Thank, that works but will a small issue. If you go to http://www.mesquitechristmas.com/local/phpsqlajax_genxml2.php You will notice it is showing an error because their is no space before lat=. Not sure how to add a space to that. // ADD TO XML DOCUMENT NODE echo '<marker '; echo 'displayname="' . parseToXML($row['displayname']) . '" '; echo 'address="'. parseToXML($row["address"]) .' '. parseToXML($row["city"]) .' '. parseToXML($row["state"]) .' ' . parseToXML($row['postal']) . '"'; echo 'lat="' . $row['lat'] . '" '; echo 'lng="' . $row['lng'] . '" '; echo '/>'; } // End XML file Any idea what I need to do?
-
Yea I think I need to be more clear. I need to merge this $row["city"] $row["state"] $row["postal"] Behind this. $row['address'] Something like this but this doesn't work. echo 'address="' . parseToXML($row['address'], $row["city"], $row["state"], $row["postal"]) . '" '; I need all that to be included in the variable address above. Hope that makes sense.
-
I am not sure how to merge this. I have tried but was unable to get it to work. What I am needing to do is add the $rows below $row["city"] $row["state"] $row["postal"] Need to add to this below behind row["address"] echo 'address="' . parseToXML($row['address']) . '" '; If anyone can help me out with this that would be great! -Thanks
-
Thanks for your help. Now if I can only figure out how to upload images with this form to the sever then store the URL of the image in the DB I will be set. Thanks
-
It just reloads and nothing is inserted into the database.
-
I have this simple form and it use to work but I was jacking around with the code to be able to upload images but I couldn't figure it out. So I went back to the last working code that submitted to the DB, but for some reason it is not working now. Maybe it is because I am tired, but does anyone see anything wrong? Here is the page http://www.mesquitechristmas.com/local/submit.php <?php // here, we check if the form has been submitted, because we need to handle // redirection before we handle outputting the HTML stuff. if (isset($_POST['submit'])) { if (empty($_POST['displayname']) || empty($_POST['displaytype']) || empty($_POST['description']) || empty($_POST['address']) || empty($_POST['city']) || empty($_POST['state']) || empty($_POST['postal']) || empty($_POST['country']) || empty($_POST['imgdata'])) { $error = '*Please fill in all fields.'; // here, they have not filled in all fields. Set an error. } else { // MAKE CONNECTION include ('db_connect.php'); $displayname = $_POST['displayname']; $displaytype = $_POST['displaytype']; $description = $_POST['description']; $address = $_POST['address']; $address2 = $_POST['address2']; $city = $_POST['city']; $state = $_POST['state']; $postal = $_POST['postal']; $country = $_POST['country']; $website = $_POST['website']; $imgdata = $_POST['imgdata']; $imgdata = file_get_contents($_FILES['imgdata']['tmp_name']); mysql_query("INSERT INTO users (displayname, displaytype, description, address, address2, city, state, postal, country, website, imgdata) VALUES ('$displayname', '$displaytype', '$description', '$address', '$address2', '$city', '$state', '$postal', '$country', '$website', '$imgdata')")or die (mysql_error()); } } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <meta name="description" content="Mesquite Texas Country Christmas" /> <meta name="keywords" content="Mesquite, Texas, Country Christmas" /> <meta name="author" content="NA" /> <link rel="stylesheet" type="text/css" href="/stylesheet.css" media="screen" title="FBC" /> <script type="text/javascript" src="drop_down.js"></script> <title>A Mesquite Country Christmas</title> </head> <body> <div id="wrap"> <a href="/index.html"> <img id="frontphoto" src="/images/header.png" width="760" height="237" alt="Mesquite Country Christmas" border="0"></a> <div id="menu"> <h2 class="hide">Menu:</h2> <ul id="avmenu"> <li><a href="/index.html">Home</a></li> <li><a href="/christmasstory.html">The Christmas Story</a></li> <li><a href="/directions.html">Directions</a></li> <li><a href="#">Information</a><ul> <li><a href="/information.html">Display Facts & Info</a></li> <li><a href="/faq.html">FAQ</a></li> <li><a href="/playlist.html">2008 Playlist</a></li> <li><a href="#">Christmas History</a></li> </ul></li> <li><a href="#">Photos</a> <ul> <li><a href="/2007photos.html">2007</a></li> </ul></li> <li><a href="#">Videos</a> <ul> <li><a href="/2007videos.html">2007</a></li> </ul></li> <li><a href="/guestbook.php">Guestbook</a></li> <li><a href="/webcam.html">Web Cam</a></li> <li><a href="/webradio.html">Internet Radio</a></li> <li><a href="http://www.noradsanta.org/" TARGET="_blank">Track Santa</a></li> <li><a href="/projects.html">Projects & How Tos</a></li> <li><a href="/links.html">Links</a></li> <li><a href="/contact_us.html">Contact Us</a></li> </ul> <center><a href="http://www.toysfortots.org/" TARGET="_blank"><img src="/images/toys_for_tots.jpg" border="0" width="110" height="153" vspace="10"></a></center> <center><a href="http://christmas.bronners.com/2007/house/534.html"><img src="http://christmas.bronners.com/voteforme/vote.jpg" border="0" width="110" height="153" alt="christmas decorations" vspace="10"></a></center> </div> <div id="content"> <div class="fadebox"> <h2> Submit your Lights</h2> <hr /> <p><img src="/images/christmas-lights.jpg" width="153" height="208" alt="Submit Lights" align="left" border="0" hspace="10"> Thank you for submitting your home to the Mesquites Country Christmas display finder database. There are some things you should know before submitting to make your experience a pleasant one.</p><p>First of all, we do not release your personal information to anyone for any reason. The only exception to this, obviously, is the address of the display, the website (if it has one), and a picture of the display.</p><p>Secondly, please have a picture available to use for your display. You won't be able to submit your display without one. When submitting a picture, please make sure that the file is less than one megabyte (1 Meg or 1024k), and if possible, resize it to 640x480. Please also be sure your picture is in JPG format.</p><p>Your display will not immediately be entered into the Christmas Light Finder database. We will first have to approve your submission. This is so that those unscrupulous folks out there can't submit unacceptable pictures (not family friendly). Please allow up to 48 hours to be included into the database, though, the time before insertion is usually much shorter than that.</p> </div> <div class="fadebox"> <h2> Ready to submit? Fill out the form below:</h2> <hr /> <br /> <form enctype="multipart/form-data" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> <table> <tr> <td>Display Name*</td><td><input name="displayname" size="40" type="text"></td></tr> <tr> <td>Display Type*</td><td><select name="displaytype"><option value="Residential">Residential</option><option value="Neighborhood">Neighborhood</option><option value="Commercial">Commercial</option><option value="City/Government">City/Government</option><option value="Sponsored">Sponsored</option></select></td></tr> <tr><td>Description*</td><td><textarea name="description" cols="30" rows="5"></textarea></td></tr> <tr><td>Address*</td><td><input name="address" size="40" type="text"></td></tr><tr><td>Address 2</td><td><input name="address2" size="40" type="text"></td></tr> <tr><td>City*</td><td><input name="city" size="30" type="text" value="Mesquite"></td></tr> <tr><td>State/Province*</td><td><input name="state" size="30" type="text" value="Texas"></td></tr> <tr><td>Postal Code*</td><td><select name="postal"><option value="75149">75149</option><option value="75150">75150</option><option value="75180">75180</option><option value="75181">75181</option><option value="75185">75185</option><option value="75187">75187</option></select></td></tr> <tr><td>Country*</td><td><input name="country" size="30" type="text" value="United States"></td></tr> <tr><td>Website</td><td><input name="website" size="50" value="http://" type="text"></td></tr> <tr><td>Picture*</td><td><input type="file" name="imgdata" size="35"></td></tr> <tr> <td colspan="2" align="right" class="errorText"> <?PHP // then we check for the error message if (isset($error)) { echo $error . '<br />'; } ?> </td> </tr> <tr><td colspan="2" style="border-top: 1px solid black;" align="right"> <br /> <input name="submit" value="Submit Now" type="submit"></td></tr> </tbody></table></form> <br>* Fields are required. <br> </div> </div> <div id="footer"> © 2007 Mesquite Country Christmas <br /> <br /> <script type="text/javascript"><!-- google_ad_client = "pub-8048181801684156"; //468x60, created 1/8/08 google_ad_slot = "0360766123"; google_ad_width = 468; google_ad_height = 60; //--></script> <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script> </div> </div> </body> </html> Any help would be great. -Thanks
-
Ok I kept playing with it and I got it. It was what I thought with the curly brackets. I was actually missing two brackets. Thanks for the help.
-
Ok I am getting this error now and I have played with it for a bit and can't get it to go away. Usally that means I haven't closed a bracket or have an extra one but they seemed to all be closed. Parse error: syntax error, unexpected $end in /home/mesquit1/public_html/local/login.php on line 194 Here is the entire file. What am I missing or doing wrong? <?php session_start(); include ('db_connect.php'); if(isset($_POST['submit'])) { if(empty($_POST['email'])) $error = 'Please fill in email field.'; elseif(empty($_POST['password'])) $error = 'Please fill in desired password field.'; else { // email and password sent from signup form $email=$_POST['email']; $password=$_POST['password']; $sql="SELECT * FROM users WHERE email='$email' and password='" . md5($password) . "'"; $result=mysql_query($sql); // Mysql_num_row is counting table row $count=mysql_num_rows($result); // If result matched $email and $password, table row must be 1 row if($count==1) { // Register $email, $password and redirect to file "user.php" $_SESSION['hasLoggedIn'] = 1; //get the users id that is associated with him $SQL2 = "SELECT * FROM users WHERE email='$email'"; $result2 = mysql_query($SQL); $row = mysql_fetch_assoc($result); //store the id in the session for use $_SESSION['userID'] = $row['id']; session_register("email"); header("location:user.php"); } else { $error = 'Wrong email or password, try again.'; } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <meta name="description" content="Mesquite Texas Country Christmas" /> <meta name="keywords" content="Mesquite, Texas, Country Christmas" /> <meta name="author" content="NA" /> <link rel="stylesheet" type="text/css" href="/stylesheet.css" media="screen" title="FBC" /> <script type="text/javascript" src="drop_down.js"></script> <title>A Mesquite Country Christmas - Login</title> </head> <body> <div id="wrap"> <a href="/index.html"> <img id="frontphoto" src="/images/header.png" width="760" height="237" alt="Mesquite Country Christmas" border="0"></a> <div id="menu"> <h2 class="hide">Menu:</h2> <ul id="avmenu"> <li><a href="/index.html">Home</a></li> <li><a href="/christmasstory.html">The Christmas Story</a></li> <li><a href="/directions.html">Directions</a></li> <li><a href="#">Information</a><ul> <li><a href="/information.html">Display Facts & Info</a></li> <li><a href="/faq.html">FAQ</a></li> <li><a href="/playlist.html">2008 Playlist</a></li> <li><a href="#">Christmas History</a></li> </ul></li> <li><a href="#">Photos</a> <ul> <li><a href="/2007photos.html">2007</a></li> </ul></li> <li><a href="#">Videos</a> <ul> <li><a href="/2007videos.html">2007</a></li> </ul></li> <li><a href="/guestbook.php">Guestbook</a></li> <li><a href="/webcam.html">Web Cam</a></li> <li><a href="/webradio.html">Internet Radio</a></li> <li><a href="http://www.noradsanta.org/" TARGET="_blank">Track Santa</a></li> <li><a href="/projects.html">Projects & How Tos</a></li> <li><a href="/links.html">Links</a></li> <li><a href="/contact_us.html">Contact Us</a></li> </ul> <center><a href="http://www.toysfortots.org/" TARGET="_blank"><img src="/images/toys_for_tots.jpg" border="0" width="110" height="153" vspace="10"></a></center> <center><a href="http://christmas.bronners.com/2007/house/534.html"><img src="http://christmas.bronners.com/voteforme/vote.jpg" border="0" width="110" height="153" alt="christmas decorations" vspace="10"></a></center> </div> <div id="content"> <div class="fadebox"> <h2>Login Now</h2> <hr /> <p>Log into your account to submit new displays as well as modify existing ones. Registration is free, so if you don't already have an account, <a href="/local/register.php">create one</a>!</p> <table width="28%" border="0" cellpadding="0" cellspacing="0"> <tr> <td> <table width="300" border="0" align="left" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC"> <tr> <form name="form1" method="post" action="login.php"> <td> <table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF"> <tr> <td colspan="3"><strong> User Login</strong></td> </tr> <tr> <td width="78"> Email:</td> <td width="294"><input name="email" type="text" id="email" size="30"></td> </tr> <tr> <td> Password:</td> <td><input name="password" type="password" id="password" size="30"></td> </tr> <tr> <td colspan="2" align="right" class="errorText"> <?PHP // then we check for the error message if (isset($error)) { echo $error . '<br />'; } ?> </td> </tr> <tr> <td colspan="2" align="right"><input type="submit" name="submit" value="Login"></td> </tr> </table> </td> </form> </tr> </table> </td> </tr> <tr> <td><table width="300" border="0" align="left" cellpadding="0" cellspacing="0"> <tr> <td> <p><a href="/local/forgot.php">Forgot Password</a> | <a href="/local/register.php">Register</a></p> </td> </tr> </table></td> </tr> </table> </div> </div> </div> <div id="footer"> © 2007 Mesquite Country Christmas <br /> <br /> <script type="text/javascript"><!-- google_ad_client = "pub-8048181801684156"; //468x60, created 1/8/08 google_ad_slot = "0360766123"; google_ad_width = 468; google_ad_height = 60; //--></script> <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script> </div> </div> </body> </html> -Thanks
-
I got it figured out..... Thanks for all your help.
-
That works but when you register it is suppose to direct you to user.php and it doesn't, it redirects to login.php. It use to redirect to user.php when you registered. <?php // here, we check if the form has been submitted, because we need to handle // redirection before we handle outputting the HTML stuff. if(isset($_POST['submit'])) { if(empty($_POST['email'])) $error = 'Please fill in email field.'; elseif(empty($_POST['password'])) $error = 'Please fill in desired password field.'; else { // MAKE CONNECTION include ('db_connect.php'); // connect to the mysql server $link = mysql_connect($host, $username, $password) or die ("Could not connect to mysql because ".mysql_error()); // select the database mysql_select_db($database) or die ("Could not select database because ".mysql_error()); $error = ""; $email = $_POST['email']; $pwd = $_POST['password']; // check if the email is taken (safe query): $query = sprintf("SELECT `email` FROM `users` WHERE `email` = '%s'", mysql_real_escape_string($_POST['email'])); $qry = mysql_query($query) or die ("Could not match data because ".mysql_error()); $num_rows = mysql_num_rows($qry); if ($num_rows < 1) { // Reverse magic_quotes_gpc/magic_quotes_sybase effects on those vars if ON. if(get_magic_quotes_gpc()) { $product_name = stripslashes($_POST['email']); $product_description = stripslashes($_POST['password']); } else { $product_name = $_POST['email']; $product_description = $_POST['password']; } if (!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})$", $product_name)){ $error = 'The email address is Invalid.'; } else { // Make a safe query $query = sprintf("INSERT INTO users (`email`, `password`) VALUES ('%s', '%s')", mysql_real_escape_string($email, $link), mysql_real_escape_string($password, $link)); $result = mysql_query($query, $link); // If there is no result, or there was not at least 1 row affected, die... if(!$result || mysql_affected_rows() < 1) { $error = 'Could not insert user because ' . mysql_error(); } else { // redirect them to the user account page, because we successfully ran the SQL // notice how we haven't output ANYTHING to the browser yet- header() works header('Location: user.php'); exit(); } } } else { $error = 'That email is already in use, please select a different one.'; } } } // If they've posted but there was an error, kindly show their email address for them again. if(isset($_POST['email'])) $email = $_POST['email']; else $email = ''; ?> Any reason why? -Thanks