
ddarsow
New Members-
Posts
6 -
Joined
-
Last visited
Never
Profile Information
-
Gender
Not Telling
ddarsow's Achievements

Newbie (1/5)
0
Reputation
-
Umm...seriously? It is defined with: $mail=$_POST['mail']; Yes, I am sure it has a value as the page is in a test environment & not live yet so I am posting the value myself from the form. Also if I echo the variable on the page it returns the expected value such as: echo $mail; returns whatever was entered into the form such as [email protected]
-
I am trying to query a MySQL database based on a user's email address which is posted from a form. The posted data echos fine, but when I use the variable to query the database I get 0 rows returned. If I use the exact same query, substituting the desired email address instead of pulling it from a variable value the query works. I assume it has something to do with the @ symbol not being interpreted correctly after being posted, but this is admittedly merely a guess. Any idea how to remedy this? The relevant code is as follows: The for posting the email address: <form action="secure/prepare.php" method="post" onsubmit="this.submit(); return false" > Please enter your email address:<br> <input type="text" name="mail" value="<?echo$mail?>" size="40"><br><br> <input type="submit" value=" Proceed to Checkout "> </form> The variable value & query on the next page: $mail=$_POST["mail"]; $query="SELECT * FROM customers WHERE cust_email = '$mail' "; I intentionally left all other code out as everything works perfect if I simply change the query to something like: $query="SELECT * FROM customers WHERE cust_email = '[email protected]' ";
-
(kicking my own butt) I had a typo in one of the table field names; I had cat_nam & should have been cat_name I looked over the code about 200 times and I swear I read name every time. Darn stupid brain. Thanks!
-
OK, once again copy & paste to create one form from another is not always a time saver! I removed the this.reset(); from the form tag so it now reads: <form class=\"mid\" action=\"updatecat.php\" method=\"post\" onsubmit=\"this.submit();\"> Also, I removed the id update & added an id field to the form. But,...still not working. It does not seem to revert back to the default when hitting the button, but it does not update the database either. The update code now reads: <? $username="***"; $password="***"; $database="***"; $id=$_POST['id']; $name=$_POST['name']; $order=$_POST['order']; $description=$_POST['description']; $sort=$_POST['sort']; $hide=$_POST['hide']; $wholesale=$_POST['wholesale']; mysql_connect(localhost,$username,$password); @mysql_select_db($database) or die( "Unable to select database"); $query = "UPDATE categories SET cat_nam='$name', cat_order='$order', cat_description='$description', cat_sorting='$sort', cat_hide='$hide', cat_wholesale='$wholesale' WHERE cat_id='$id'"; mysql_query($query); mysql_close(); ?> <script language="javascript"> location.replace("admin.php?page=category"); </script>
-
I have a form which pre-fills some text areas from the results of a MySQL query and is intended to update the record when submitted. For some reason though the values reset to the prefilled data and do not edit when submitting. The form code is: <?php if (isset($_GET['id'])) { $id = $_GET['id']; } ?> <? $username="***"; $password="***"; $database="***"; mysql_connect(localhost,$username,$password); @mysql_select_db($database) or die( "Unable to select database"); $query="SELECT * FROM categories WHERE cat_id=$id"; $result=mysql_query($query); $catname=mysql_result($result,$i,"cat_name"); $catorder=mysql_result($result,$i,"cat_order"); $catdescription=mysql_result($result,$i,"cat_description"); $catsorting=mysql_result($result,$i,"cat_sorting"); $cathide=mysql_result($result,$i,"cat_hide"); $catwholesale=mysql_result($result,$i,"cat_wholesale"); mysql_close(); echo" <p class=\"nopad\">Simply modify the information below to modify this category.<br>Need help with the form? Hover your cursor on the [?] beside each field to learn more.</p> <table class=\"main\" cellspacing=\"0\"> <tbody> <tr> <td class=\"head\" colspan=\"3\"> <h1 class=\"table\">Edit an Existing Category</h1> </td> </tr> <tr cellpadding=\"5\"> <td class=\"padleft\" clospan=\"3\"> <p> <form class=\"mid\" action=\"updatecat.php\" method=\"post\" onsubmit=\"this.submit(); this.reset(); return false\"> <strong>Category Name:</strong> <input type=\"text\" name=\"name\" value=\"$catname\" size=\"35\"> <strong><a class=\"tip\" href=\"#\">[?]<span>The category name will be displayed in the left navigation on your site.</span></a></strong><br><br> <input type=\"hidden\" name=\"order\" value=\"$catorder\"> <strong>Category Description:</strong><br><textarea cols=\"75\" rows=\"10\" name=\"description\">$catdescription</textarea> <strong><a class=\"tip\" href=\"#\">[?]<span>The category description displays above the products on the category page. You may use html code to include images and format the text if desired. For more information on using html, see the main help link above or contact opti-CART</span></a></strong><br><br> <strong>Sort Products By:</strong> <SELECT NAME=\"sort\"> <OPTION>$catsorting</OPTION> <OPTION>SKU ASC</OPTION> <OPTION>SKU DESC</OPTION> <OPTION>Price ASC</OPTION> <OPTION>Price DESC</OPTION> </SELECT> <strong><a class=\"tip\" href=\"#\">[?]<span>This simply determines how the products are sorted on the category page.</span></a></strong><br> <strong>Hidden?:</strong> <SELECT NAME=\"feature\"> <OPTION>$cathide</OPTION> <OPTION>N</OPTION> <OPTION>Y</OPTION> </SELECT> <strong><a class=\"tip\" href=\"#\">[?]<span>Hidden categories will not display on your site. This is useful when you are working on a new category, for seasonal categories, or any time you wish to not show some products.</span></a></strong><br> <strong>Wholesale?:</strong> <SELECT NAME=\"feature\"> <OPTION>$catwholesale</OPTION> <OPTION>N</OPTION> <OPTION>Y</OPTION> </SELECT> <strong><a class=\"tip\" href=\"#\">[?]<span>If the wholesale option is enabled the category will only display when a registered wholesale customer logs in to the site. Wholesale categories are hidden from retail customers.</span></a></strong> <br><br><input type=\"Submit\" value=\"Save Changes\"><br> </form> </p> </td> </tr> <tr> <td class=\"head\" colspan=\"3\" height=\"30px\"> </td> </tr> </tbody> </table>" ?> The page it submits to is: <? $username="***"; $password="***"; $database="***"; $id=$_POST['id']; $name=$_POST['name']; $order=$_POST['order']; $description=$_POST['description']; $sort=$_POST['sort']; $hide=$_POST['hide']; $wholesale=$_POST['wholesale']; mysql_connect(localhost,$username,$password); @mysql_select_db($database) or die( "Unable to select database"); $query = "UPDATE categories SET cat_id='$id', cat_nam='$name', cat_order='$order', cat_description='$description', cat_sort='$sort', cat_hide='$hide', cat_wholesale='$wholesale' WHERE cat_id='$id'"; mysql_query($query); mysql_close(); ?> <script language="javascript"> location.replace("admin.php?page=category"); </script> Anyone know how to make this actually edit the table and not reset to the original values pulled from the database when submitting? Thanks, Dave
-
I am trying to upload images (and some other data) to a mysql database from a php file. The "other data" associated with the images uploads, but the images themselves do not. The code is as follows: ADD IMAGE FORM: 1. <h1>Upload a New Image</h1> 2. <p>To add a new image, simply fill in the form below and click on the "Upload Image" button located at the bottom of this page. To upload additional images for the property, simply repeat the process for each image.</p> 3. <p> 4. <form class="mid" action="insert_img.php" method="post" onsubmit="this.submit(); this.reset(); return false" enctype="multipart/form-data"> 5. <strong>MLS Number: (REQUIRED!)</strong> <input type="text" name="mls" size="30"><br><br> 6. <strong>IMAGE:</strong> <input name="image" type="file"><br><br> 7. <strong>Thumbnail?:</strong> 8. <SELECT NAME="tn"> 9. <OPTION>N</OPTION> 10. <OPTION>Y</OPTION> 11. </SELECT><br><br> 12. <strong>Alt Text:</strong> <input type="text" name="alt" size="30"><br><br> 13. <strong>Image Title:</strong> <input type="text" name="title" size="60"><br><br> 14. <br><input type="Submit" value="Upload Image"> <input type="reset" value="clear form"> 15. </form> 16. </p> INSERT to DB SCRIPT: 1. <? 2. $username="*****"; 3. $password="*****"; 4. $database="*******"; 5. 6. $mls=$_POST['mls']; 7. $tn=$_POST['tn']; 8. $alt=$_POST['alt']; 9. $title=$_POST['title']; 10. $image=$_POST['image']; 11. 12. $path = $_FILES['image']['tmp_name']; 13. $name = $_FILES['image']['name']; 14. $size = $_FILES['image']['size']; 15. $type = $_FILES['image']['type']; 16. 17. 18. mysql_connect(localhost,$username,$password); 19. @mysql_select_db($database) or die( "Unable to select database"); 20. 21. $query = "INSERT INTO images VALUES ('{}','{$mls}','{$tn}','{$alt}','{$title}','{$name}','{$size}','{$type}','{$image}')"; 22. mysql_query($query); 23. 24. mysql_close(); 25. 26. ?> 27. 28. <script language="javascript"> 29. location.replace("admin.php?page=addimage2"); 30. </script> The field I am trying to insert the images into is a mediumblob Any thoughts? I am new to php, so I suspect it is something simple. Thanks, Dave