Jump to content

minneapolis

New Members
  • Posts

    3
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

minneapolis's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. i am trying to add a change password function to a project and i am getting an error. Could somebody take a look at the following code: [code] <?php   //this page lets the a user change their password //check if the form has been submitted if (isset($_POST['submitted'])) {     //connect to the DB     $dbcn = new mysqli                      ("localhost","ics325sp0604", "13855",  "ics325sp0604" );     if(mysqli_connect_errno())    {               echo "<p>Error creating database connection: </p>";             exit;       }     //create a function for escaping the data     function escape_data($data) {         global $dbcn;         if (ini_get('magic_quotes_gpc')) {             $data = stripslashes($data);         }                 return mysqli_real_escape_string(trim($data), $dbcn);     }     $errors = array(); //check for an email address if (empty($_POST['email'])) {     $errors[] = 'You forgot to enter your email address'; } else {     $e = escape_data($_POST['email']); } //check for an existing password if (empty($_POST['password'])) {     $errors[] = 'You forgot to enter your existing password'; } else {     $p = escape_data($_POST['password']); } if (empty($errors)) {     //check that they have entered the right email password     $query = "SELECT username FROM user_info         WHERE (email = '$e' AND password=SHA('$p'))";     $result = $dbcn->query($query);     if (mysqli_num_rows($result) == 1) {         //get the username         $row = mysqli_fetch_array($result, MYSQLI_NUM);         $query = "UPDATE user_info SET password=SHA('$np') WHERE username=$row[0]";         $result = $dbcn->query($query);             if (mysqli_affected_rows() == 1) {                 echo 'Thank You! Your password has been updated';     } else {         echo 'Your password has not been changed';     } } } ?> <html> <head> <title> Password form</title> </head> <body> <h2>change your password</h2>     <form action="password.php" method = "post">         <p>Email address: <input type ="text" name="email" size="20" maxlength="40"         value="<?php if         (isset($_POST['email'])) echo $_POST         ['email']; ?> /> </p>              <p>Current Password: <input type ="password" name="password" size="10" maxlength="20" />         </p>                          <p>New Password: <input type ="password" name="password" size="10" maxlength="20" />         </p>                          <p>Confirm New Password: <input type ="password" name="password" size="10" maxlength="20" />         </p>             <p><input type="submit" name="submit"         value="Change My Password" /></p>         <input type="hidden" name="submitted" value="TRUE" />     </form> </body> <html>   [/code] The error is the following: Parse error: parse error, unexpected $ in /home/students/ics325sp06/ics325sp0604/public_html/project4/password.php on line 123
  2. toplay thanks for the prompt reply, however when i do what you suggested , the only info i get is : Step 1 - Please Enter Billing and Shipping Information Step 2 - Please verify that your order is accurate Step3 - Order Confirmation and Receipt [code] ?php session_start(); //connect to the DB $connect = new mysqli("localhost","ics325sp0604", "13855", "ics325sp0604" ); //declare the necessary variables $firstname = $_POST['firtsname']; $lastname = $_POST['lastsname']; $add1 = $_POST['add1']; $add2 = $_POST['add2']; $city = $_POST['city']; $state = $_POST['state']; $zip = $_POST['zip']; $phone = $_POST['phone']; $fax = $_POST['fax']; $email = $_POST['email']; $shipfirst = $_POST['shipfirst']; $shiplast = $_POST['shiplast']; $shipadd1 = $_POST['shipadd1']; $shipadd2 = $_POST['shipadd2']; $shipcity = $_POST['shipcity']; $shipstate = $_POST['shipstate']; $shipzip = $_POST['shipzip']; $shipphone = $_POST['shipphone']; $shipemail = $_POST['shipemail']; $total = $_POST['total']; $sessid = session_id(); $today = date("y - m- d"); // Assign a CU Number $query = "SELECT FROM customers WHERE     (customers_firstname = '$firstname' AND     customers_lastname = '$lastname' AND         customers_add1 = '$add1' AND     customers_add2 = '$add2' AND     customers_city = '$city')"; $results = $connect->query($query); $rows = $results->num_rows; if ($rows < 1) {     $query2 = "INSERT INTO customers (         customers_firstname, customers_lastname, customers_add1,         customers_add2, customers_city, customers_state,         customers_zip, customers_phone, customers_fax,         customers_email)         VALUES (         '$firstname',         '$lastname',         '$add1',         '$add2',         '$city',         '$state',         '$zip',         '$phone',         '$fax',         '$email')";     $insert = $connect->query($query2);     $custid = $connect->insert_id; } //CU exists ?? if ($custid) {     $customers_custnum = $custid; } $shipping = $total * 0.25; $query3 = "INSERT INTO ordermain (     ordermain_orderdate, ordermain_custnum,     ordermain_subtotal, ordermain_shipping,     ordermain_shipfirst, ordermain_shiplast,     ordermain_shipadd1, ordermain_shipadd2,     ordermain_shipcity, ordermain_shipstate,     ordermain_shipzip, ordermain_shipphone,     ordermain_shipemail)          VALUES (     '$today',     '$customers_custnum',     '$total',     '$shipping',     '$shipfirst',     '$shiplast',     '$shipadd1',     '$shipadd2',     '$shipcity',     '$shipstate',     '$shipzip',     '$shipphone',     '$shipemail')"; $insert2 = $connect->query($query3); $orderid = $connect->insert_id; //insert information captured $query = "SELECT * FROM carttemp WHERE carttemp_sess='$sessid'"; $results = mysqli_query($connect, $query); //put data in the DB while ($row = mysqli_fetch_array($results)) {     extract($row);     $query4 = "INSERT INTO orderdet(     orderdet_ordernum, orderdet_qty, orderdet_prodnum)          VALUES (     '$orderid',     '$carttemp_quan',     '$carttemp_prodnum')"; $insert4 = $connect->query($query4); } //delete from temp table $query = "DELETE FROM carttemp WHERE carttemp_sess = '$sessid'"; $delete = $connect->query($query); //Send Email $to = "<" . $email .">"; $subject = "Order Confirmation"; $message = " <html> <head> <title>Order Confirmation</title> </head> <body> Your order as submitted<br><br> Order date: "; $message .=$today; $message .= "     <br>     Order Number: "; $message .= $orderid; $message .= "     <table width=\"50%\" border=\"0\">         <tr>             <td>                 <p>Bill to:<br>"; $message .= $firstname; $message .= " "; $message .= $lastname; $message .= "<br>"; $message .= $add1; $message .= "<br>"; if ($add2) {     $message .= $add2 . "<br>"; } $message .= $city . ", " . $state . " " . $zip; $message .="</p></td>     <td>     <p>Ship to:<br>"; $message .= $shipfirst . " " . $shiplast; $message .= "<br>"; $message .= $shipadd1 . "<br>";     if ($shipadd2) {         $message .= $shipadd2 . "<br>";     } $message .= $shipcity . ", " . $shipstate . " " . $shipzip; $message .= "</p>     </td>     </tr>     </table>     <hr width=\"250px\" align=\"left\">     <table cellpadding=\"5\">"; //insert into the message $query = "SELECT * FROM orderdet WHERE orderdet_ordernum = '$orderid'"; $results = $connect->query($query); while ($row = mysqli_fetch_array($results)) {     extract($row);     $prod = "SELECT * FROM products         WHERE products_prodnum = '$orderdet_prodnum'";          $prod2 = $connect->query($prod);     $prod3 = mysqli_fetch_array($results);     extract($prod3);          $message .= "<tr><td>";     $message .= $orderdet_qty;     $message .= "</td>";     $message .= "<td>";     $message .= $products_name;     $message .= "</td>";     $message .= "<td align=\"right\">";     $message .= $products_price;     $message .= "</td>";     $message .= "<td align=\"right\">";          $extprice = number_format($products_price * orderdet_qty, 2);     $message .= $extprice;     $message .= "</td>";     $message .= "</tr>"; }     $message .= "<tr>         <td colspan=\"3\" align=\"right\">             Your Total before shipping is:         </td>         <td align =\"right\">";     $message .= number_format($total, 2);     $message .= "         </td>         </tr>         <tr>         <td colspan=\"3\" align=\"right\">             Shipping costs:         </td>                 <td align=\"right\">";     $message .= number_format(($total + $shipping), 2);     $message .= "         </td>         </tr> </table> </body> </html>"; $headers .=  "From:<lznaidi@hotmail.com>\r\n"; mail($to, $subject, $message, $headers); echo "Step 1 - Please Enter Billing and Shipping Information<br>"; echo "Step 2 - Please verify that your order is accurate<br>"; echo "<strong>Step3 - Order Confirmation and Receipt</strong><br><br>"; //echo $message; ?> [/code] i would appreciate if someone can point me to the right direction because i am loosing it with this code.... Thanks for the help
  3. I have this weird error::: Call to a member function fetch_array() on a non-object . code is the following::: //connect to the DB $connect = new mysqli("localhost","ics325sp0604", "13855", "ics325sp0604" ); .....(CUT) //insert information captured $query = "SELECT FROM carttemp WHERE carttemp_sess='$sessid'"; $results = mysqli_query($connect, $query); //put data in the DB while ($row = mysqli_fetch_array($results)) { //line 105 extract($row); $query4 = "INSERT INTO orderdet( orderdet_ordernum, orderdet_qty, orderdet_prodnum) .......(CUT) The error is Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean given in /home/students/ics325sp06/ics325sp0604/public_html/project4/checkout3.php on line 105 Step 1 - Please Enter Billing and Shipping Information Step 2 - Please verify that your order is accurate Step3 - Order Confirmation and Receipt i tried several combination like: $row = $connect->fetch_array($results).... or $row = $results->fetch_array() But NO GO... Can anybody help... Thanks again
×
×
  • 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.