Jump to content

sjones

Members
  • Posts

    42
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

sjones's Achievements

Member

Member (2/5)

0

Reputation

  1. Hello, I am making a simple login script, and I can’t get the proper results from the query. I will post the code below. When I enter the username and password, I query the database for a match and it comes back that it does not match. I have gone to the phpmyadmin and changed the password several times to the same password that I am typing in. I have it in a password field in the database. I am wondering if the MySQL Collation has anything to do with it?? Could you please look at my code and see if you can find anything that may be interfering with positive results. I have redone this script several times, I have confirmed that the mysql_connect.php include is working. I have looked at the error logs and below is the only error in there: ERROR LOG PHP Notice: Undefined variable: logged_in_user in /home/virtual/site11/fst/var/www/html/new2009/properties/index.php on line 13, referer: http://www.bdrycleveland.com/new2009/properties/index.php I am suspecting the password field (Just a hunch) Here is the code: <?php session_start() ?> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <title>Untitled Document</title> </head> <body> <?php if ($username && $password) { if ($logged_in_user == $username) { echo $username. ", you are already logged in.<br><br>"; exit(); } require_once ('../connections/mysql_connect.php'); $result = mysql_query("SELECT * FROM user WHERE user_name = '".$username."' AND user_password = PASSWORD('".$password."')"); if (!$result) { echo "Sorry, there has been a technical hitch. We cannot enter your details."; exit(); } if (mysql_num_rows($result) >0 ) { $logged_in_user = $username; session_register("logged_in_user"); echo "Welcome, ".$logged_in_user.".<br><br>"; exit(); } else { echo "Invalid login, Please try again.<br><br>"; } } else if ($username || $password) { echo "Please fill in both fields<br><br>"; } ?> <form method="post" action="index.php"> <p>Username:<br><input name="username" type="text" size="12" maxlength="12"></p> <p>Password:<br><input name="password" type="password" size="12" maxlength="12"></p> <p><input name="submit" type="submit" value="Submit"></p> </form> </body> </html> The Database table is very simple also: Field Type Collation Attributes Null Default Extra Action user_id smallint(5) UNSIGNED ZEROFILL No auto_increment user_name varchar(12) latin7_general_cs No user_password varchar(12) latin7_general_cs No Thanks for any help.
  2. I have two tables one for products (product) and one for orders (orders) The product description is in the product table (product_short_desc). However the session_id is in the orders table (cart_session_id) this query below will return everything from the orders table (but no product description obviously) $query = "SELECT * FROM orders WHERE (cart_session_id = '".$sid."')"; ___________________________________________________ Then I tried this one and get "Zero" results $query = "SELECT orders.product_name, orders.cart_quantity, product.product_short_desc FROM orders, product WHERE orders.cart_session_id = '".$sid."' AND orders.product_name = product.product_name"; I'm just in building phase now so any suggestions on how I can achieve this will be helpfull - Thanks
  3. The other user had pointed out that I did not put the PHP in tags and that it was hard to read. So I marked the other one as solved and posted the topic with the PHP in tags. I did not see a way to edit the original post or I would have put the tags around the original. If you know a way of editing the original, I would be happy to put that in quotes.
  4. Hello, I am working on a site and I need some guidance please. I have a form that I would like to store two values in a session. All I need is the product and the quantity. Now I get the product from the form fields – size, color, logo, and voltage using a switch/case. And I get the quantity from the form field quantity. I would like to store these values in a session variable and be able to go back and add to, delete, or edit the variable. My goal is to be able to figure out what products and quantity the client needs. Then send email order to the warehouse for processing. I am having trouble storing the value and adding to it, whenever I go back and use the form the only output I get is the current values. It over writes the old data. If you want to visit what I have now you can see it at (http://www.rediheat.com/feb2008/order.php?f=single_pie) the only form working now is single_pie Any Help? here is my code: <?php include 'includes/header.inc'; ?> <table width="887" border="0" align="center" cellpadding="0" cellspacing="0"> <tr> <td valign="top"><img src="images/spacer.gif" width="880" height="1"></td> <td rowspan="2"><img src="images/spacer.gif" width="7" height="466"></td> </tr> <tr> <!-- This is where the ordering form will be placed --> <td valign="top" class="product_article" style="background-image:url(images/order_page_bg.jpg); background-repeat:no-repeat; "> <div style="padding-left:14px; padding-top:10px; "> <!-- This area is where the include files will be --> <?php $allowed_inc = array('single_pie', 'multi_pie', 'food_service', 'element'); if (isset($_POST['single_pie_submit'])) { // THIS IS WHERE THE PRODUCTS WILL BE ADDED TO THE DATABASE require_once ('connection/mysql_connect.php'); // Connect to the database. $error_message = ""; if ($size != "blank") { $size = $_POST['size']; } else { $error_message .= "<p>You forgot to enter a size</p> "; } if ($color != "blank") { $color = $_POST['color']; } else { $error_message .= "<p>You forgot to choose a color!</p> "; } if ($logo!= "blank") { $logo = $_POST['logo']; } else { $error_message .= "<p>You need to choose if you would like a logo on your bag </p> "; } if ($voltage!= "blank") { $voltage = $_POST['voltage']; } else { $error_message .= "<p>You did not choose the electrical voltage that you require </p>"; } if ($quantity != "") { $quantity = $_POST['quantity']; } else { $error_message .= "<p>You did not select a quantity </p>"; } if (strlen($error_message) > 1) { // IF THERE WAS AN ERROR echo $error_message . "<p>Click <a href='javascript:history.back()'>here</a> to go back</p>"; echo "</div> </td> </tr> </table>"; include 'includes/footer.inc'; exit(); } else { // WE NEED TO PROCESS THE ORDER NOW if ($size && $color && $logo && $voltage && $quantity) { // IF ALL VARIABLES ARE TRUE ############################## ## SWITCH / CASE ### ############################## $product = $size . $color . $logo . $voltage; switch ($product) { case '16redno110'; $prod='HP101'; break; case '16redno220'; $prod='HP105'; break; case '16redyes110'; $prod='HP103'; break; case '16redyes220'; $prod='HP108'; break; case '16blackno110'; $prod='HP113'; break; case '16blackno220'; $prod='HP115'; break; case '16blackyes110'; $prod='HP114'; break; case '16blackyes220'; $prod='HP116'; break; case '16greenno110'; $prod='HP119'; break; case '16greenyes110'; $prod='HP120'; break; case '16greenno220'; $prod='HP000'; break; case '16greenyes220'; $prod='HP000'; break; case '18redno110'; $prod='HP102'; break; case '18redno220'; $prod='HP106'; break; case '18redyes110'; $prod='HP104'; break; case '18redyes220'; $prod='HP109'; break; case '18blackno110'; $prod='HP112'; break; case '18blackno220'; $prod='HP117'; break; case '18blackyes110'; $prod='HP110'; break; case '18blackyes220'; $prod='HP118'; break; case '18greenno110'; $prod='HP121'; break; case '18greenyes110'; $prod='HP122'; break; case '18greenno220'; $prod='HP000'; break; case '18greenyes220'; $prod='HP000'; break; } ############################## ## END OF SWITCH / CASE ## ############################## $cart_prod = $prod. "," .$quantity. "-" ; session_register('cart_prod'); echo $cart_prod; echo " </div> </td> </tr> </table>"; include 'includes/footer.inc'; exit(); } } } if (isset($_POST['multi_pie_submit'])) { // THIS IS WHERE THE PRODUCTS WILL BE ADDED TO THE DATABASE echo "Multi pie submit button was set </div> </td> </tr> </table>"; include 'includes/footer.inc'; exit(); } if (isset($_POST['food_service_submit'])) { // THIS IS WHERE THE PRODUCTS WILL BE ADDED TO THE DATABASE echo "Food service submit button was set </div> </td> </tr> </table>"; include 'includes/footer.inc'; exit(); } if (isset($_POST['element_submit'])) { // THIS IS WHERE THE PRODUCTS WILL BE ADDED TO THE DATABASE echo "Element submit button was set </div> </td> </tr> </table>"; include 'includes/footer.inc'; exit(); } // page specified -> load content from relevant text file if (isset($_GET['f']) and in_array($_GET['f'], $allowed_inc)) { include("includes/" . $_GET['f'] . ".inc"); // no page specified -> load content from default.inc } else { include("includes/products_default.inc"); } ?> <!-- This area is the end of the include files --> </div> </td> </tr> </table> <?php include 'includes/footer.inc'; ?>
  5. Hello, I am working on a site and I need some guidance please. I have a form that I would like to store two values in a session. All I need is the product and the quantity. Now I get the product from the form fields – size, color, logo, and voltage using a switch/case. And I get the quantity from the form field quantity. I would like to store these values in a session variable and be able to go back and add to, delete, or edit the variable. My goal is to be able to figure out what products and quantity the client needs. Then send email order to the warehouse for processing. I am having trouble storing the value and adding to it, whenever I go back and use the form the only output I get is the current values. It over writes the old data. If you want to visit what I have now you can see it at (http://www.rediheat.com/feb2008/order.php?f=single_pie) the only form working now is single_pie Any Help? here is my code: <?php include 'includes/header.inc'; ?> <table width="887" border="0" align="center" cellpadding="0" cellspacing="0"> <tr> <td valign="top"><img src="images/spacer.gif" width="880" height="1"></td> <td rowspan="2"><img src="images/spacer.gif" width="7" height="466"></td> </tr> <tr> <!-- This is where the ordering form will be placed --> <td valign="top" class="product_article" style="background-image:url(images/order_page_bg.jpg); background-repeat:no-repeat; "> <div style="padding-left:14px; padding-top:10px; "> <!-- This area is where the include files will be --> <?php $allowed_inc = array('single_pie', 'multi_pie', 'food_service', 'element'); if (isset($_POST['single_pie_submit'])) { // THIS IS WHERE THE PRODUCTS WILL BE ADDED TO THE DATABASE require_once ('connection/mysql_connect.php'); // Connect to the database. $error_message = ""; if ($size != "blank") { $size = $_POST['size']; } else { $error_message .= "<p>You forgot to enter a size</p> "; } if ($color != "blank") { $color = $_POST['color']; } else { $error_message .= "<p>You forgot to choose a color!</p> "; } if ($logo!= "blank") { $logo = $_POST['logo']; } else { $error_message .= "<p>You need to choose if you would like a logo on your bag </p> "; } if ($voltage!= "blank") { $voltage = $_POST['voltage']; } else { $error_message .= "<p>You did not choose the electrical voltage that you require </p>"; } if ($quantity != "") { $quantity = $_POST['quantity']; } else { $error_message .= "<p>You did not select a quantity </p>"; } if (strlen($error_message) > 1) { // IF THERE WAS AN ERROR echo $error_message . "<p>Click <a href='javascript:history.back()'>here</a> to go back</p>"; echo "</div> </td> </tr> </table>"; include 'includes/footer.inc'; exit(); } else { // WE NEED TO PROCESS THE ORDER NOW if ($size && $color && $logo && $voltage && $quantity) { // IF ALL VARIABLES ARE TRUE ############################## ## SWITCH / CASE ### ############################## $product = $size . $color . $logo . $voltage; switch ($product) { case '16redno110'; $prod='HP101'; break; case '16redno220'; $prod='HP105'; break; case '16redyes110'; $prod='HP103'; break; case '16redyes220'; $prod='HP108'; break; case '16blackno110'; $prod='HP113'; break; case '16blackno220'; $prod='HP115'; break; case '16blackyes110'; $prod='HP114'; break; case '16blackyes220'; $prod='HP116'; break; case '16greenno110'; $prod='HP119'; break; case '16greenyes110'; $prod='HP120'; break; case '16greenno220'; $prod='HP000'; break; case '16greenyes220'; $prod='HP000'; break; case '18redno110'; $prod='HP102'; break; case '18redno220'; $prod='HP106'; break; case '18redyes110'; $prod='HP104'; break; case '18redyes220'; $prod='HP109'; break; case '18blackno110'; $prod='HP112'; break; case '18blackno220'; $prod='HP117'; break; case '18blackyes110'; $prod='HP110'; break; case '18blackyes220'; $prod='HP118'; break; case '18greenno110'; $prod='HP121'; break; case '18greenyes110'; $prod='HP122'; break; case '18greenno220'; $prod='HP000'; break; case '18greenyes220'; $prod='HP000'; break; } ############################## ## END OF SWITCH / CASE ## ############################## $cart_prod = $prod. "," .$quantity. "-" ; session_register('cart_prod'); echo $cart_prod; echo " </div> </td> </tr> </table>"; include 'includes/footer.inc'; exit(); } } } if (isset($_POST['multi_pie_submit'])) { // THIS IS WHERE THE PRODUCTS WILL BE ADDED TO THE DATABASE echo "Multi pie submit button was set </div> </td> </tr> </table>"; include 'includes/footer.inc'; exit(); } if (isset($_POST['food_service_submit'])) { // THIS IS WHERE THE PRODUCTS WILL BE ADDED TO THE DATABASE echo "Food service submit button was set </div> </td> </tr> </table>"; include 'includes/footer.inc'; exit(); } if (isset($_POST['element_submit'])) { // THIS IS WHERE THE PRODUCTS WILL BE ADDED TO THE DATABASE echo "Element submit button was set </div> </td> </tr> </table>"; include 'includes/footer.inc'; exit(); } // page specified -> load content from relevant text file if (isset($_GET['f']) and in_array($_GET['f'], $allowed_inc)) { include("includes/" . $_GET['f'] . ".inc"); // no page specified -> load content from default.inc } else { include("includes/products_default.inc"); } ?> <!-- This area is the end of the include files --> </div> </td> </tr> </table> <?php include 'includes/footer.inc'; ?>
  6. Hello, I am working on a site for a small town newspaper. They have about 5 people that will FTP articles in .pdf format. Each article is between 500K and 2mg – approximately 30 pages, so 60mg max. I setup a user named “news” on the server, so everyone can access the same directory. I setup the FTP site “news” and the current issue is to be put in a folder called “current_issue”. However, I can not CHMOD this directory. (it is restricted) - with it being restricted I can’t call the .pdf file into the page with an include statement. I talked with tech support this morning and they said I could setup a “symbolic link” on the UNIX server to the "news/current_issue" directory and I’m not quite sure how that will work. The purpose of the FTP site was to allow them to just upload the current issue and always name the page "current_1.pdf", "current_2.pdf" and so on.... (for page one and two) and then the php script would look for current_1.pdf or whatever in the "news" FTP directory . Has anyone come across this or does anyone have any suggestions as to the path they would take.
  7. I have looked in the php.ini file and error reporting is ON. I still don't have any idea why this won't work. The following line of code was added. $result = mysql_query($query) or die ("Error in: $query" .mysql_error()); Not only did I get no errors, the script continued and did not die??? I am answering one of the above questions with the code below, Any thoughts? _____________________________ The variables are defined in this table. //////////THIS IS THE FORM THAT FEEDS THE TOP FORM THE INFO/////// if (isset($_GET['submit'])) { $article_id == $_GET['article_id']; if ($article_id < 1 ){ echo "<span class='nav_default'>You did not select an article.</span><br><br>"; echo "<span class='default'><a href='javascript:history.back()'><strong>Back</strong></a></span>"; include 'footer.inc'; exit(); }else{ include '../connections/mysql_connect.php'; $query = "SELECT * FROM news WHERE id ='".$article_id."';" ; $result = mysql_query($query); $record = mysql_fetch_assoc($result); echo "<form action='edit_news.php' method='post' name='article_select'> <p class='default'><strong>News Headline/Title: </strong><br> <input name='title' type='text' size='50' maxlength='120' value='".$record['title']."'> <br> <br> <strong>Author:</strong> <br> <input name='author' type='text' size='50' maxlength='120' value='".$record['author']."'> <br> <br> <strong>Do You want this article to appear on the Main Page?</strong> <br> <input name='main_page' type='checkbox' value='yes'>Yes <input name='main_page' type='checkbox' value='no'>No<br><br> <strong>Article Text:</strong><br> <textarea name='description' cols='50' rows='6'>".$record['description']."</textarea> <br> <br> </p> <p> <input name='submit' type='submit' value='Submit'> <input name='reset' type='reset'> </p> </form> <p style='width:480px; '><span class='nav_default'><strong>* </strong>If you would like to add an image to this article. You will need to use the 'Add Image to News Article' link in the Image section of the Main admin page. After you submit this article.</span></p>"; include 'footer.inc'; exit(); } }
  8. When I tried this fix from the firs reply. $result = mysql_query($query) or die ("Error in: $query" mysql_error()); My page won't even open and I get no error. Just a blank page. Any thoughts?
  9. Hello, I have worked many hours to troubleshoot why this won't work. I have read at least 15 post on UPDATE. I still can't get this to work. When I submit the form. It says that the udate took place, however it did not. I will put the form below, this is the section that is supposed to update the DB. I will also put the form below this one that feeds the info. Any help would be greatly appreciated. //UPDATE FORM///////// if ($title && $description && $main_page) { $news_id = $_POST['id']; $title = $_POST['title']; $description = $_POST['description']; $author = $_POST['author']; $main_page_display = $_POST['main_page']; include '../connections/mysql_connect.php'; $query = "UPDATE `news` SET `title` = '".$_POST['title']."', `description` ='".$_POST['description']."', `author` ='".$_POST['author']."' , `main_page` ='".$_POST['main_page_display']."' WHERE `id` ='".$_POST['id']."';" ; $result = mysql_query($query); if ($result) { if ($main_page_display == "yes") { $mpd = "This article will be displayed on the Main Page"; }else{ $mpd = "This article will not be displayed on the Main Page"; } echo "<span class='default'><strong>The following information has been changed in the database!</strong><br><br> <strong>Title:</strong> ".$title. "<br><strong>By:</strong> ".$author."<br><br> <strong>" .$mpd. "</strong><br><br> <strong>Description:</strong><br>".$description."<br><br> <a href='edit_news.php'>Click here to edit another article</a> <a href='index.php'>Click here to go to the main page</a> <a href='logout.php'>Click here to Logout</a>"; }else{ echo "No results where edited in the Database"; } } echo "<span class='default'><a href='javascript:history.back()'>Back</a></span>"; include 'footer.inc'; exit; } ////////// END OF TOP FORM ////////////////////// //////////THIS IS THE FORM THAT FEEDS THE TOP FORM THE INFO/////// if (isset($_GET['submit'])) { $article_id == $_GET['article_id']; if ($article_id < 1 ){ echo "<span class='nav_default'>You did not select an article.</span><br><br>"; echo "<span class='default'><a href='javascript:history.back()'><strong>Back</strong></a></span>"; include 'footer.inc'; exit(); }else{ include '../connections/mysql_connect.php'; $query = "SELECT * FROM news WHERE id ='".$article_id."';" ; $result = mysql_query($query); $record = mysql_fetch_assoc($result); echo "<form action='edit_news.php' method='post' name='article_select'> <p class='default'><strong>News Headline/Title: </strong><br> <input name='title' type='text' size='50' maxlength='120' value='".$record['title']."'> <br> <br> <strong>Author:</strong> <br> <input name='author' type='text' size='50' maxlength='120' value='".$record['author']."'> <br> <br> <strong>Do You want this article to appear on the Main Page?</strong> <br> <input name='main_page' type='checkbox' value='yes'>Yes <input name='main_page' type='checkbox' value='no'>No<br><br> <strong>Article Text:</strong><br> <textarea name='description' cols='50' rows='6'>".$record['description']."</textarea> <br> <br> </p> <p> <input name='submit' type='submit' value='Submit'> <input name='reset' type='reset'> </p> </form> <p style='width:480px; '><span class='nav_default'><strong>* </strong>If you would like to add an image to this article. You will need to use the 'Add Image to News Article' link in the Image section of the Main admin page. After you submit this article.</span></p>"; include 'footer.inc'; exit(); } }
  10. O.K I have solved it - This returns the the title and the URL - hopefully helpfull for the archive <marquee scrolldelay="160" width="594" direction="left"> <?php include 'connections/mysql_connect.php'; $sql = 'SELECT * FROM `events` ORDER BY `date_created` LIMIT 0, 30'; $result = mysql_query($sql); while ($record = mysql_fetch_assoc($result)){ echo "<a href=".$record['url'].">".$record['title']. "</a> " ; } ?> </marquee>
  11. That code above does not work for returning the url - its all just one big <a href> with the value of the last url returned. any help on how to return the title and url from the DB and scroll it in a marquee.??
  12. O.K so I have changed it to this <marquee scrolldelay="160" width="594" direction="left"> <?php include 'connections/mysql_connect.php'; $sql = 'SELECT * FROM `events` ORDER BY `date_created` LIMIT 0, 30'; $result = mysql_query($sql); while ($record = mysql_fetch_assoc($result)){ $text .= $record['title'].' '; } echo "<span class='default'>" .$text. " </span>"; ?> </marquee> ____________________________________________________________________ This ia returning the titles in one line. Now I have to work on the <a href> tag that will pull the URL for the article that goes with the headline that was returned. Will what I have below work? - using the $url <marquee scrolldelay="160" width="594" direction="left"> <?php include 'connections/mysql_connect.php'; $sql = 'SELECT * FROM `events` ORDER BY `date_created` LIMIT 0, 30'; $result = mysql_query($sql); while ($record = mysql_fetch_assoc($result)){ $url = $record['url']; $text .= $record['title'].' '; } echo "<span class='default'><a href=".$url.">" .$text. "</a> </span>"; ?> </marquee>
  13. Hello, I'm trying to return titles of events and scroll them in a <marquee> tag -but they are stacked on top of each other. Is there a way to have them one after another. Below is the code I am using. <? include 'connections/mysql_connect.php'; $sql = 'SELECT * FROM `events` ORDER BY `date_created` LIMIT 0, 30'; $result = mysql_query($sql); while ($record = mysql_fetch_assoc($result)){ $text = $record['title']; echo "<marquee scrolldelay='160' width='594' direction='left'><span class='default'><a href='news.php'>" .$record['title']. "</a></span></marquee>"; } ?>
  14. Hello, I am trying to have a form that gives a user 8 different choices. These would be with radio buttons. The user can select as many of those that they want, from 0-8. I then want to echo the results in the handle_form.php script. QUESTION: would I set up the form using something like: <input name="choice" type="checkbox" value="choice1"> <input name="choice" type="checkbox" value="choice2"> <input name="choice" type="checkbox" value="choice3"> or would I use <input name="choice1" type="checkbox" value="true"> <input name="choice2" type="checkbox" value="true"> <input name="choice3" type="checkbox" value="true"> And then I need to know how to get only the results that the user checked in the handle_form.php script. $choice = $_POST['choice']; for ($i =0; $i < count($choice); $i++) echo $choice[$i] . ", "; I know this may be very simple but my brain is not working correctly. when I use a similar code I only get the first letter of the value and if a user selects more that one choice I only get the first letter of the last choice.??? Any help would be appreciated
  15. O.K. - I'm using this code. $text = $record['description']; echo "<p><span class='eventsLocation2'>" .$record['title']. "</span><br><br><div align='right'>" . join(' ', array_slice (explode(' ', $text), 0, 12)) . " <a href='news.php'><span class='read_more'>....READ MORE</span></a></div></p><br>"; I'm running into a problem when the description that is typed in has any type of formatting such as <b></b> if the closing tag is not before the cutoff then all of the other entries are bold. You can view this example @ http://www.cwptechnologies.com/2007newsite/index.php - if you look at the right side of the page you will see the truncated events section and you will see that once the bold tag was used it was never closed. Any thoughts?
×
×
  • 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.