Jump to content

andyonline2011

New Members
  • Posts

    5
  • Joined

  • Last visited

    Never

Everything posted by andyonline2011

  1. ah thanks,makes perfect sense..now i changed the mysql to mysqli so im using the same method.
  2. tried it,still have this error Warning: mysql_fetch_assoc() expects parameter 1 to be resource, object given in C:\wamp\www\store\include\shippingAndPaymentInfo.php on line 23 what did you mean with the mixing of sql and sqli?
  3. thanks for replies! I've tried both suggestions, and no success with either. :shrug:mike, i was ok up until i tried to echo the results within my form,i could'nt work the syntax out.with all the backslashes in your example it looks like what i've seen when a php display block is used,im not using one so i think thats the problem. mjdamato, i tried what you posted but am getting errors: Warning: mysqli_query() expects parameter 1 to be mysqli, string given in C:\wamp\www\store\include\shippingAndPaymentInfo.php on line 22 and Warning: mysql_fetch_assoc() expects parameter 1 to be resource, null given in C:\wamp\www\store\include\shippingAndPaymentInfo.php on line 23 as for validation, i agree, but that form is only accessible after a successful login,so there should always be a value for cu_id.
  4. hi everyone, Im trying to make a checkout page, where if the user is logged in, the address information is called from the database and fills the form automatically, my problem is i don't know how to fill the php variables with the result of my sql query..sorry to be a complete noob but can someone explain how i would do this? <?php if (!defined('WEB_ROOT') || !isset($_GET['step']) || (int)$_GET['step'] != 1) { exit; } require_once 'loginfunctions.php'; checkCustomerLogin(); $errorMessage = ' '; ?> <?php // get the customer id from the session. $cu_id = $_SESSION['cu_id'] ?> <?php //connect to server $mysqli = mysqli_connect("localhost", "root", "", "onlinestore"); //get default shipping and payment address $mysql = "SELECT cu_id,od_shipping_first_name,od_shipping_last_name,od_shipping_address1,od_shipping_address2,od_shipping_phone,od_shipping_city,od_shipping_state,od_shipping_postal_code FROM tbl_customer WHERE $cu_id = cu_id"; $result = mysqli_query($mysql,$mysqli); $row = mysql_fetch_assoc($result); //populate form with values ? $txtShippingFirstName = 'test'; $txtShippingLastName = 'test'; $txtShippingAddress1 = 'test'; $txtShippingAddress2 = 'test'; $txtShippingPhone = 'test'; $txtShippingState = 'test'; $txtShippingCity = 'test'; $txtShippingPostalCode = 'test'; ?> <script language="JavaScript" type="text/javascript" src="library/checkout.js"></script> <table width="550" border="0" align="center" cellpadding="10" cellspacing="0"> <tr> <td>Step 1 Of 3 : Please Confirm Shipping And Payment Information </td> </tr> </table> <p id="errorMessage"><?php echo $errorMessage; ?></p> <form action="<?php echo $_SERVER['PHP_SELF']; ?>?step=2" method="post" name="frmCheckout" id="frmCheckout" onSubmit="return checkShippingAndPaymentInfo();"> <table width="550" border="0" align="center" cellpadding="5" cellspacing="1" class="entryTable"> <tr class="entryTableHeader"> <td colspan="2">Shipping Information</td> </tr> <tr> <td width="150" class="label">First Name</td> <td class="content"><input name="txtShippingFirstName" type="text" class="box" id="txtShippingFirstName" value="<?php echo $txtShippingFirstName ?>" size="30" maxlength="50"></td> </tr> <tr> <td width="150" class="label">Last Name</td> <td class="content"><input name="txtShippingLastName" type="text" class="box" id="txtShippingLastName" value="<?php echo $txtShippingLastName ?>" size="30" maxlength="50"></td> </tr> <tr> <td width="150" class="label">Address1</td> <td class="content"><input name="txtShippingAddress1" type="text" class="box" id="txtShippingAddress1" value="<?php echo $txtShippingAddress1 ?>" size="50" maxlength="100"></td> </tr> <tr> <td width="150" class="label">Address2</td> <td class="content"><input name="txtShippingAddress2" type="text" class="box" id="txtShippingAddress2" value="<?php echo $txtShippingAddress2 ?>" size="50" maxlength="100"></td> </tr> <tr> <td width="150" class="label">Phone Number</td> <td class="content"><input name="txtShippingPhone" type="text" class="box" id="txtShippingPhone" value="<?php echo $txtShippingPhone ?>" size="30" maxlength="32"></td> </tr> <tr> <td width="150" class="label">Province / State</td> <td class="content"><input name="txtShippingState" type="text" class="box" id="txtShippingState" value="<?php echo $txtShippingState ?>" size="30" maxlength="32"></td> </tr> <tr> <td width="150" class="label">City</td> <td class="content"><input name="txtShippingCity" type="text" class="box" id="txtShippingCity" value="<?php echo $txtShippingCity ?>" size="30" maxlength="32"></td> </tr> <tr> <td width="150" class="label">Postal / Zip Code</td> <td class="content"><input name="txtShippingPostalCode" type="text" class="box" id="txtShippingPostalCode" value="<?php echo $txtShippingPostalCode ?>" size="10" maxlength="10"></td> </tr> </table> <p> </p> <table width="550" border="0" align="center" cellpadding="5" cellspacing="1" class="entryTable"> <tr class="entryTableHeader"> <td width="150">Payment Information</td> <td><input type="checkbox" name="chkSame" id="chkSame" value="checkbox" onClick="setPaymentInfo(this.checked);"> <label for="chkSame" style="cursor:pointer">Same as shipping information</label></td> </tr> <tr> <td width="150" class="label">First Name</td> <td class="content"><input name="txtPaymentFirstName" type="text" class="box" id="txtPaymentFirstName" size="30" maxlength="50"></td> </tr> <tr> <td width="150" class="label">Last Name</td> <td class="content"><input name="txtPaymentLastName" type="text" class="box" id="txtPaymentLastName" size="30" maxlength="50"></td> </tr> <tr> <td width="150" class="label">Address1</td> <td class="content"><input name="txtPaymentAddress1" type="text" class="box" id="txtPaymentAddress1" size="50" maxlength="100"></td> </tr> <tr> <td width="150" class="label">Address2</td> <td class="content"><input name="txtPaymentAddress2" type="text" class="box" id="txtPaymentAddress2" size="50" maxlength="100"></td> </tr> <tr> <td width="150" class="label">Phone Number</td> <td class="content"><input name="txtPaymentPhone" type="text" class="box" id="txtPaymentPhone" size="30" maxlength="32"></td> </tr> <tr> <td width="150" class="label">Province / State</td> <td class="content"><input name="txtPaymentState" type="text" class="box" id="txtPaymentState" size="30" maxlength="32"></td> </tr> <tr> <td width="150" class="label">City</td> <td class="content"><input name="txtPaymentCity" type="text" class="box" id="txtPaymentCity" size="30" maxlength="32"></td> </tr> <tr> <td width="150" class="label">Postal / Zip Code</td> <td class="content"><input name="txtPaymentPostalCode" type="text" class="box" id="txtPaymentPostalCode" size="10" maxlength="10"></td> </tr> </table> <p> </p> <table width="550" border="0" align="center" cellpadding="5" cellspacing="1" class="entryTable"> <tr> <td width="150" class="entryTableHeader">Payment Method </td> <td class="content"> <input name="optPayment" type="radio" id="optPaypal" value="paypal" checked="checked" /> <label for="optPaypal" style="cursor:pointer">Paypal</label> <input name="optPayment" type="radio" value="cod" id="optCod" /> <label for="optCod" style="cursor:pointer">Cash on Delivery</label></td> </tr> </table> <p> </p> <p align="center"> <input class="box" name="btnStep1" type="submit" id="btnStep1" value="Proceed >>"> </p> </form>
  5. Hi everyone, im working on a e comm site as a project. I have a register.php page, and its supposed to check for the presence of posted data, and if data is not posted show a form block,and if posted data is present insert it into a database. However its not working,i get an unexpected } on line 114, where there is a }else{ . I've only been working with php a few days, but from what i've read the braces seem where they should be,can someone please tell me where the problem is? <script language="JavaScript" type="text/javascript" src="library/checkout.js"></script> <?php //set up a couple of functions function doDB() { global $mysqli; //connect to server and select database; you may need it $mysqli = mysqli_connect("localhost", "root", "", "onlinestore"); } //determine if they need to see the form or not if (!$_POST) { //they need to see the form, so create form block $display_block = " <form name=\"register\" method=\"post\"action=\"index.php?r=1\"\ id=\"register\"> <table width=\"550\" border=\"0\" align=\"center\" cellpadding=\"5\" cellspacing=\"1\" class=\"entryTable\"> <tr class=\"entryTableHeader\"> <td colspan=\"2\">Login Details</td> </tr> <tr> <td width=\"150\" class=\"label\">Email</td> <td class=\"content\"><input name\=\"txtEmail\" type=\"text\" class=\"box\" id=\"txtEmail\" size=\"30\" maxlength=\"50\"></td> </tr> <tr> <td width=\"150\" class=\"label\">Password</td> <td class=\"content\"><input name=\"txtPassword\" type=\"password\" class=\"box\" id=\"txtPassword\" size=\"30\" maxlength=\"50\"></td> </tr> </table> <p> </p> <table width=\"550\" border=\"0\" align=\"center\" cellpadding=\"5\" cellspacing=\"1\" class=\"entryTable\"> <tr class=\"entryTableHeader\"> <td colspan=\"2\">Shipping Information</td> </tr> <tr> <td width=\"150\" class=\"label\">First Name</td> <td class=\"content\"><input name=\"txtShippingFirstName\" type=\"text\" class=\"box\" id=\"txtShippingFirstName\" size=\"30\" maxlength=\"50\"></td> </tr> <tr> <td width=\"150\" class=\"label\">Last Name</td> <td class=\"content\"><input name=\"txtShippingLastName\" type=\"text\" class=\"box\" id=\"txtShippingLastName\" size=\"30\" maxlength=\"50\"></td> </tr> <tr> <td width=\"150\" class=\"label\">Address1</td> <td class=\"content\"><input name=\"txtShippingAddress1\" type=\"text\" class=\"box\" id=\"txtShippingAddress1\" size=\"50\" maxlength=\"100\"></td> </tr> <tr> <td width=\"150\" class=\"label\">Address2</td> <td class=\"content\"><input name=\"txtShippingAddress2\" type=\"text\" class=\"box\" id=\"txtShippingAddress2\" size=\"50\" maxlength=\"100\"></td> </tr> <tr> <td width=\"150\" class=\"label\">Phone Number</td> <td class=\"content\"><input name=\"txtShippingPhone\" type=\"text\" class=\"box\" id=\"txtShippingPhone\" size=\"30\" maxlength=\"32\"></td> </tr> <tr> <td width=\"150\" class=\"label\">Area</td> <td class=\"content\"><input name=\"txtShippingState\" type=\"text\" class=\"box\" id=\"txtShippingState\" size=\"30\" maxlength=\"32\"></td> </tr> <tr> <td width=\"150\" class=\"label\">City</td> <td class=\"content\"><input name=\"txtShippingCity\" type=\"text\" class=\"box\" id=\"txtShippingCity\" size=\"30\" maxlength=\"32\"></td> </tr> <tr> <td width=\"150\" class=\"label\">Post Code</td> <td class=\"content\"><input name=\"txtShippingPostalCode\" type=\"text\" class=\"box\" id=\"txtShippingPostalCode\" size=\"10\" maxlength=\"10\"></td> </tr> </table> <p> </p> <table width=\"550\" border=\"0\" align=\"center\" cellpadding=\"5\" cellspacing=\"1\" class=\"entryTable\"> <tr class=\"entryTableHeader\"> <td width=\"150\">Payment Information</td> <td><input type=\"checkbox\" name=\"chkSame\" id=\"chkSame\" value=\"checkbox\" onClick=\"setPaymentInfo(this.checked);\"> <label for=\"chkSame\" style=\"cursor:pointer\">Same as shipping information</label></td> </tr> <tr> <td width=\"150\" class=\"label\">First Name</td> <td class=\"content\"><input name=\"txtPaymentFirstName\" type=\"text\" class=\"box\" id=\"txtPaymentFirstName\" size=\"30\" maxlength=\"50\"></td> </tr> <tr> <td width=\"150\" class=\"label\">Last Name</td> <td class=\"content\"><input name=\"txtPaymentLastName\" type=\"text\" class=\"box\" id=\"txtPaymentLastName\" size=\"30\" maxlength=\"50\"></td> </tr> <tr> <td width=\"150\" class=\"label\">Address1</td> <td class=\"content\"><input name=\"txtPaymentAddress1\" type=\"text\" class=\"box\" id=\"txtPaymentAddress1\" size=\"50\" maxlength=\"100\"></td> </tr> <tr> <td width=\"150\" class=\"label\">Address2</td> <td class=\"content\"><input name=\"txtPaymentAddress2\" type=\"text\" class=\"box\" id=\"txtPaymentAddress2\" size=\"50\" maxlength=\"100\"></td> </tr> <tr> <td width=\"150\" class=\"label\">Phone Number</td> <td class=\"content\"><input name=\"txtPaymentPhone\" type=\"text\" class=\"box\" id=\"txtPaymentPhone\" size=\"30\" maxlength=\"32\"></td> </tr> <tr> <td width=\"150\" class=\"label\">Area</td> <td class=\"content\"><input name=\"txtPaymentState\" type=\"text\" class=\"box\" id=\"txtPaymentState\" size=\"30\" maxlength=\"32\"></td> </tr> <tr> <td width=\"150\" class=\"label\">City</td> <td class=\"content\"><input name=\"txtPaymentCity\" type=\"text\" class=\"box\" id=\"txtPaymentCity\" size=\"30\" maxlength=\"32\"></td> </tr> <tr> <td width=\"150\" class=\"label\">Post Code</td> <td class=\"content\"><input name=\"txtPaymentPostalCode\" type=\"text\" class=\"box\" id=\"txtPaymentPostalCode\" size=\"10\" maxlength=\"10\"></td> </tr> </table> <p> </p> <p> </p> <p align=\"center\"> <input class=\"box\" name=\"btnStep1\" type=\"submit\" id=\"btnStep1\" value=\"Proceed >>\"> </p> </form>" } else { //connect to database doDB(); //add records $add_sql = "INSERT INTO tbl_customer (email) VALUES('".$_POST["txtEmail"]."')"; $add_sql = "INSERT INTO tbl_customer (password) VALUES('".$_POST["txtPassword"]."')"; $add_sql = "INSERT INTO tbl_customer (od_shipping_first_name) VALUES('".$_POST["txtShippingFirstName"]."')"; $add_sql = "INSERT INTO tbl_customer (od_shipping_last_name) VALUES('".$_POST["txtShippingLastName"]."')"; $add_sql = "INSERT INTO tbl_customer (od_shipping_address1) VALUES('".$_POST["txtShippingAddress1"]."')"; $add_sql = "INSERT INTO tbl_customer (od_shipping_address2) VALUES('".$_POST["txtShippingPhone"]."')"; $add_sql = "INSERT INTO tbl_customer (od_shipping_phone) VALUES('".$_POST["txtShippingState"]."')"; $add_sql = "INSERT INTO tbl_customer (od_shipping_city) VALUES('".$_POST["txtShippingCity"]."')"; $add_sql = "INSERT INTO tbl_customer (od_shipping_state) VALUES('".$_POST["txtShippingState"]."')"; $add_sql = "INSERT INTO tbl_customer (od_shipping_postal_code) VALUES('".$_POST["txtShippingPostalCode"]."')"; $add_sql = "INSERT INTO tbl_customer (od_payment_first_name) VALUES('".$_POST["txtPaymentFirstName"]."')"; $add_sql = "INSERT INTO tbl_customer (od_payment_last_name) VALUES('".$_POST["txtPaymentLastName"]."')"; $add_sql = "INSERT INTO tbl_customer (od_payment_address1) VALUES('".$_POST["txtPaymentAddress1"]."')"; $add_sql = "INSERT INTO tbl_customer (od_payment_address2) VALUES('".$_POST["txtPaymentPhone"]."')"; $add_sql = "INSERT INTO tbl_customer (od_payment_phone) VALUES('".$_POST["txtPaymentState"]."')"; $add_sql = "INSERT INTO tbl_customer (od_payment_city) VALUES('".$_POST["txtPaymentCity"]."')"; $add_sql = "INSERT INTO tbl_customer (od_payment_state) VALUES('".$_POST["txtPaymentState"]."')"; $add_sql = "INSERT INTO tbl_customer (od_payment_postal_code) VALUES('".$_POST["txtPaymentPostalCode"]."')"; $add_res = mysqli_query($mysqli, $add_sql) or die(mysqli_error($mysqli)); $display_block = "<p>Thanks for signing up!</p>"; } ?>
×
×
  • 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.