Jump to content

MsKazza

Members
  • Posts

    92
  • Joined

  • Last visited

Everything posted by MsKazza

  1. so like this? <?php //Database connect if (!$con = mysql_connect("mysql1.myhost.ie","admin_book","root123")) { die('Could not connect: ' . mysql_error()); } mysql_select_db("book_test", $con); //CLEAN POST VALUES foreach ($_POST as $k=>$v) { $_POST[$k] = mysql_real_escape_string(trim($v)); } $sql="INSERT INTO custdetails (orderid, name, surname, add1, add2, town, county, postcode, phone, email, letterstyle) VALUES ('" . $_POST['orderid'] . "','" . $_POST['name'] . "','" . $_POST['surname'] . "','" . $_POST['add1'] . "','" . $_POST['add2'] . "','" . $_POST['town'] . "','" . $_POST['country'] . "','" . $_POST['postcode'] . "','" . $_POST['phone'] . "','" . $_POST['email'] . "','" . $_POST['letterstyle'] . "')"; $cardpayment = mysql_query(sprintf("SELECT qty FROM cards WHERE orderid = " . $_POST['orderid']), $book) or die(mysql_error()); $row_cardpayment = mysql_fetch_assoc($cardpayment); $totalRows_cardpayment = mysql_num_rows($cardpayment); $qty = $row_cardpayment; if (!mysql_query($sql)) { die('Error: ' . mysql_error()); } ?> it still gives me a blank page
  2. would it be something along the lines of : SET qty = $cardpayment as cardpayment gets the value i asked the recordset to lookup.
  3. i thought the qty was being taken from the recordset ($cardpayment = mysql_query(sprintf("SELECT qty FROM cards WHERE orderid = " . $_POST['orderid']), $book) or die(mysql_error()) but then i guess that is only retrieving it, i need to set the variable afterwards?
  4. ok, i've cleaned it up a bit, taken out the other db connect. and made some changes to the $row2 bit <?php //Database connect if (!$con = mysql_connect("mysql1.myhost.ie","admin_book","root123")) { die('Could not connect: ' . mysql_error()); } mysql_select_db("book_test", $con); //CLEAN POST VALUES foreach ($_POST as $k=>$v) { $_POST[$k] = mysql_real_escape_string(trim($v)); } $sql="INSERT INTO custdetails (orderid, name, surname, add1, add2, town, county, postcode, phone, email, letterstyle) VALUES ('$orderid','$name','$surname','$add1','$add2','$town','$county','$postcode','phone','$email','$letterstyle')"; $cardpayment = mysql_query(sprintf("SELECT qty FROM cards WHERE orderid = $orderid"), $book) or die(mysql_error()); $row_cardpayment = mysql_fetch_assoc($cardpayment); $totalRows_cardpayment = mysql_num_rows($cardpayment); if (!mysql_query($sql)) { die('Error: ' . mysql_error()); } ?> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>Digital Scribe Books</title> <link href="style.css" rel="stylesheet" type="text/css" /> <script type="text/javascript"> function MM_preloadImages() { //v3.0 var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array(); var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++) if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}} } function MM_swapImgRestore() { //v3.0 var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc; } function MM_findObj(n, d) { //v4.01 var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) { d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);} if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n]; for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); if(!x && d.getElementById) x=d.getElementById(n); return x; } function MM_swapImage() { //v3.0 var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3) if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];} } </script> </head> <body onload="MM_preloadImages('images/buttons/home_over.png','images/buttons/books_over.png','images/buttons/cards_over.png','images/buttons/letters_over.png')"> <div id="snow"> <div id="wrapper"> <div id="header"> <div id="logo"><img src="images/digital_scripe.png" width="218" height="91" /></div> <div id="menu"><a href="index.php" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Home','','images/buttons/home_over.png',1)"><img src="images/buttons/home_act.png" name="Home" width="131" height="132" border="0" id="Home" /></a><a href="books.php" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Books','','images/buttons/books_over.png',1)"><img src="images/buttons/books_act.png" name="Books" width="131" height="132" border="0" id="Books" /></a><a href="cards.php" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Cards','','images/buttons/cards_over.png',1)"><img src="images/buttons/cards_act.png" name="Cards" width="131" height="132" border="0" id="Cards" /></a><a href="letters.php" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Letters','','images/buttons/letters_over.png',1)"><img src="images/buttons/letters_act.png" name="Letters" width="131" height="132" border="0" id="Letters" /></a></div> </div> <div id="content"> <?php echo 'Order ID is : '. $orderid . '.<br />'; if ($qty == 10) echo "<div> <form action=\"https://www.paypal.com/cgi-bin/webscr\" method=\"post\"> <input type=\"hidden\" name=\"cmd\" value=\"_xclick\"> <input type=\"hidden\" name=\"business\" value=\"accounts@agraphics.ie\"> <input type=\"hidden\" name=\"lc\" value=\"IE\"> <input type=\"hidden\" name=\"item_name\" value=\"10 Christmas Cards\"> <input type=\"hidden\" name=\"item_number\" value=\"$orderid\"> <input type=\"hidden\" name=\"amount\" value=\"12.99\"> <input type=\"hidden\" name=\"currency_code\" value=\"EUR\"> <input type=\"hidden\" name=\"button_subtype\" value=\"services\"> <input type=\"hidden\" name=\shipping\" value=\"2.99\"> <input type=\"hidden\" name=\"return\" value=\"http://www.digitalscribe/thanks.php\"> <input type=\"hidden\" name=\"bn\" value=\"PP-BuyNowBF:btn_buynowCC_LG.gif:NonHosted\"> <input type=\"image\" src=\"https://www.paypalobjects.com/en_US/i/btn/btn_buynowCC_LG.gif\" border=\"0\" name=\"submit\" alt=\"PayPal - The safer, easier way to pay online!\"> <img alt=\"\" border=\"0\" src=\"https://www.paypalobjects.com/en_US/i/scr/pixel.gif\" width=\"1\" height=\"1\"> </form> </div>"; if ($qty == 20) echo "<div> <form action=\"https://www.paypal.com/cgi-bin/webscr\" method=\"post\"> <input type=\"hidden\" name=\"cmd\" value=\"_xclick\"> <input type=\"hidden\" name=\"business\" value=\"accounts@agraphics.ie\"> <input type=\"hidden\" name=\"lc\" value=\"IE\"> <input type=\"hidden\" name=\"item_name\" value=\"20 Christmas Cards\"> <input type=\"hidden\" name=\"item_number\" value=\"$orderid\"> <input type=\"hidden\" name=\"amount\" value=\"21.99\"> <input type=\"hidden\" name=\"currency_code\" value=\"EUR\"> <input type=\"hidden\" name=\"button_subtype\" value=\"services\"> <input type=\"hidden\" name=\"shipping\" value=\"2.99\"> <input type=\"hidden\" name=\"return\" value=\"http://www.digitalscribe/thanks.php\"> <input type=\"hidden\" name=\"bn\" value=\"PP-BuyNowBF:btn_buynowCC_LG.gif:NonHosted\"> <input type=\"image\" src=\"https://www.paypalobjects.com/en_US/i/btn/btn_buynowCC_LG.gif\" border=\"0\" name=\"submit\" alt=\"PayPal - The safer, easier way to pay online!\"> <img alt=\"\" border=\"0\" src=\"https://www.paypalobjects.com/en_US/i/scr/pixel.gif\" width=\"1\" height=\"1\"> </form> </div>"; ?> </div> <div id="footer" class="clear"><div id="sign"><div id="sign_text">Personalised<br /> Books</div> </div></div> </div></div> </body> </html> <?php mysql_free_result($cardpayment); ?> i still get a blank page, and when i check source there is nothing there either
  5. i must sound like such a ditz, sorry. i used dreamweaver to create the recordset, guess should have done it myself, was trying to save time. the site is digitalscribe.ie the option for cards. don't want the user to see two buy now buttons, i thought would be a simple if else statement if qty ==10 then show top div else show other one. but have to first filter the orderid to the one in post
  6. ok i must be missing something, well i must have done it wrong. i'm trying to look up a record with orderid = 32343255 (e.g.) and from that record check if the qty is either 10 or 20 then depending on that display the correct div. i now just get a blank page. even the echo 'Order ID is : '. $orderid . '.<br />'; is blank. also one more quick question: why is colname_cardpayment = -1? believe me i pay it forward, have been teaching my sister all she needs to know to do my perfect job, its for her that i'm doing this page and i love trying to solve problems, i can sit for hours trying to get something to work. normally i would have done this myself, only my sister needs this for tomorrow. but like u say i much rather someone point me in the right direction and i learn it myself. thought i was doing quite well too, i've self taught myself everything i know so far in the last few months. loving php
  7. sorry i normally do check my code, was just so excited to see it work. been working on this site for a while. i'll make sure to check and double check everything in future so i don't make any more silly post/mistakes lol
  8. Thank you for your response. when i tried that code i got this error: HTTP Error 500 (Internal Server Error): An unexpected condition was encountered while the server was attempting to fulfill the request.
  9. Hi , I know my code sucks but i'm learning fast!! I'm trying to show a form if the qty value in a database == 10 or a different form if the value ==20. I tried but failed. Any help really appreciated. <?php require_once('Connections/book.php'); ?> <?php $colname_cardpayment = "-1"; if (isset($_GET['orderid'])) { $colname_cardpayment = (get_magic_quotes_gpc()) ? $_GET['orderid'] : addslashes($_GET['orderid']); } mysql_select_db($database_book, $book); $query_cardpayment = sprintf("SELECT * FROM cards WHERE orderid = '%s' ORDER BY qty ASC", $colname_cardpayment); $cardpayment = mysql_query($query_cardpayment, $book) or die(mysql_error()); $row_cardpayment = mysql_fetch_assoc($cardpayment); $totalRows_cardpayment = mysql_num_rows($cardpayment); // Database connect $con = mysql_connect("mysql1.myhost.ie","admin_book","root123"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("book_test", $con); //Parse Values from Coupon.php Form $orderid = mysql_real_escape_string(trim($_POST['orderid'])); $name = mysql_real_escape_string(trim($_POST['name'])); $surname = mysql_real_escape_string(trim($_POST['surname'])); $add1 = mysql_real_escape_string(trim($_POST['add1'])); $add2 = mysql_real_escape_string(trim($_POST['add2'])); $town = mysql_real_escape_string(trim($_POST['town'])); $county = mysql_real_escape_string(trim($_POST['county'])); $postcode = mysql_real_escape_string(trim($_POST['postcode'])); $phone = mysql_real_escape_string(trim($_POST['phone'])); $email = mysql_real_escape_string(trim($_POST['email'])); $letterstyle = mysql_real_escape_string(trim($_POST['letterstyle'])); $sql="INSERT INTO custdetails (orderid, name, surname, add1, add2, town, county, postcode, phone, email, letterstyle) VALUES ('$orderid','$name','$surname','$add1','$add2','$town','$county','$postcode','phone','$email','$letterstyle')"; if (!mysql_query($sql)) { die('Error: ' . mysql_error()); } ?> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>Digital Scribe Books</title> <link href="style.css" rel="stylesheet" type="text/css" /> <script type="text/javascript"> function MM_preloadImages() { //v3.0 var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array(); var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++) if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}} } function MM_swapImgRestore() { //v3.0 var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc; } function MM_findObj(n, d) { //v4.01 var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) { d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);} if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n]; for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); if(!x && d.getElementById) x=d.getElementById(n); return x; } function MM_swapImage() { //v3.0 var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3) if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];} } </script> </head> <body onload="MM_preloadImages('images/buttons/home_over.png','images/buttons/books_over.png','images/buttons/cards_over.png','images/buttons/letters_over.png')"> <div id="snow"> <div id="wrapper"> <div id="header"> <div id="logo"><img src="images/digital_scripe.png" width="218" height="91" /></div> <div id="menu"><a href="index.php" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Home','','images/buttons/home_over.png',1)"><img src="images/buttons/home_act.png" name="Home" width="131" height="132" border="0" id="Home" /></a><a href="books.php" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Books','','images/buttons/books_over.png',1)"><img src="images/buttons/books_act.png" name="Books" width="131" height="132" border="0" id="Books" /></a><a href="cards.php" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Cards','','images/buttons/cards_over.png',1)"><img src="images/buttons/cards_act.png" name="Cards" width="131" height="132" border="0" id="Cards" /></a><a href="letters.php" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Letters','','images/buttons/letters_over.png',1)"><img src="images/buttons/letters_act.png" name="Letters" width="131" height="132" border="0" id="Letters" /></a></div> </div> <div id="content"> <?php echo 'Order ID is : '. $orderid . '.<br />'; if ($row2['qty'] == 10) echo "<div> <form action="https://www.paypal.com/cgi-bin/webscr" method="post"> <input type="hidden" name="cmd" value="_xclick"> <input type="hidden" name="business" value="accounts@agraphics.ie"> <input type="hidden" name="lc" value="IE"> <input type="hidden" name="item_name" value="10 Christmas Cards"> <input type="hidden" name="item_number" value="<? echo $orderid; ?>"> <input type="hidden" name="amount" value="12.99"> <input type="hidden" name="currency_code" value="EUR"> <input type="hidden" name="button_subtype" value="services"> <input type="hidden" name="shipping" value="2.99"> <input type="hidden" name="return" value="http://www.digitalscribe/thanks.php"> <input type="hidden" name="bn" value="PP-BuyNowBF:btn_buynowCC_LG.gif:NonHosted"> <input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_buynowCC_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!"> <img alt="" border="0" src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" width="1" height="1"> </form> </div>"; if ($row2['qty'] == 20) echo "<div> <form action="https://www.paypal.com/cgi-bin/webscr" method="post"> <input type="hidden" name="cmd" value="_xclick"> <input type="hidden" name="business" value="accounts@agraphics.ie"> <input type="hidden" name="lc" value="IE"> <input type="hidden" name="item_name" value="20 Christmas Cards"> <input type="hidden" name="item_number" value="<? echo $orderid; ?>"> <input type="hidden" name="amount" value="21.99"> <input type="hidden" name="currency_code" value="EUR"> <input type="hidden" name="button_subtype" value="services"> <input type="hidden" name="shipping" value="2.99"> <input type="hidden" name="return" value="http://www.digitalscribe/thanks.php"> <input type="hidden" name="bn" value="PP-BuyNowBF:btn_buynowCC_LG.gif:NonHosted"> <input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_buynowCC_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!"> <img alt="" border="0" src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" width="1" height="1"> </form> </div>"; ?> </div> <div id="footer" class="clear"><div id="sign"><div id="sign_text">Personalised<br /> Books</div> </div></div> </div></div> </body> </html> <?php mysql_free_result($cardpayment); ?>
  10. Hi all, I've made a page the variables are being recieved and echo'd ok, however they are not being inserted into the database. below is the file with the insert statement. any help really appreciated. MsKazza <?php // Database connect $con = mysql_connect("mysql1.myhost.ie","admin_book","root123"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("book_test", $con); $orderid=$_GET['orderid']; //Parse Values from Coupon.php Form $orderid = mysql_real_escape_string(trim($_POST['orderid'])); $design = mysql_real_escape_string(trim($_POST['design'])); $childname = mysql_real_escape_string(trim($_POST['childname'])); $address = mysql_real_escape_string(trim($_POST['address'])); echo $orderid; echo $design; echo $childname; echo $address; $sql="INSERT INTO details (orderid, design, childname, address) VALUES ('$orderid','$design','$childname','$address')"; ?> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>Digital Scribe Books</title> <link href="style.css" rel="stylesheet" type="text/css" /> <script type="text/javascript"> function MM_preloadImages() { //v3.0 var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array(); var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++) if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}} } function MM_swapImgRestore() { //v3.0 var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc; } function MM_findObj(n, d) { //v4.01 var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) { d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);} if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n]; for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); if(!x && d.getElementById) x=d.getElementById(n); return x; } function MM_swapImage() { //v3.0 var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3) if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];} } </script> </head> <body onload="MM_preloadImages('images/buttons/home_over.png','images/buttons/books_over.png','images/buttons/cards_over.png','images/buttons/letters_over.png')"> <div id="snow"> <div id="wrapper"> <div id="header"> <div id="logo"><img src="images/digital_scripe.png" width="218" height="91" /></div> <div id="menu"><a href="index.php" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Home','','images/buttons/home_over.png',1)"><img src="images/buttons/home_act.png" name="Home" width="131" height="132" border="0" id="Home" /></a><a href="books.php" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Books','','images/buttons/books_over.png',1)"><img src="images/buttons/books_act.png" name="Books" width="131" height="132" border="0" id="Books" /></a><a href="cards.php" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Cards','','images/buttons/cards_over.png',1)"><img src="images/buttons/cards_act.png" name="Cards" width="131" height="132" border="0" id="Cards" /></a><a href="letters.php" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Letters','','images/buttons/letters_over.png',1)"><img src="images/buttons/letters_act.png" name="Letters" width="131" height="132" border="0" id="Letters" /></a></div> </div> <div id="content"> <div id="info_bar"><br /><br /><br /> <p>Your personal order number is:</p><br /> <br /> <p>Please fill out the details of where you would like your order to be shipped to.</p> </div> <form action="card_paynow.php" method="POST" name="custdetails" id="custdetails"> <table width="60%" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="19%">orderid</td> <td width="81%"><input name="orderid" type="hidden" value="<? echo $orderid; ?>"></td> </tr> <tr> <td>name</td> <td><input name="name" type="text" id="name"></td> </tr> <tr> <td>surname</td> <td><input name="surname" type="text" id="surname"></td> </tr> <tr> <td>address 1 </td> <td><input name="add1" type="text" id="add1"></td> </tr> <tr> <td>address 2 </td> <td><input name="add2" type="text" id="add2"></td> </tr> <tr> <td>town</td> <td><input name="town" type="text" id="town"></td> </tr> <tr> <td>county</td> <td><input name="county" type="text" id="county"></td> </tr> <tr> <td>postcode</td> <td><input name="postcode" type="text" id="postcode"></td> </tr> <tr> <td>number</td> <td><input name="phone" type="text" id="phone"></td> </tr> <tr> <td>email</td> <td><input name="email" type="text" id="email"></td> </tr> <tr> <td> </td> <td> </td> </tr> <tr> <td> </td> <td><input type="submit" name="Submit" value="Continue..."></td> </tr> <tr> <td> </td> <td> </td> </tr> </table> </form> </div> <div id="footer" class="clear"><div id="sign"><div id="sign_text">Personalised<br /> Books</div> </div></div> </div></div> </body> </html>
  11. Hi all, I have my whole script working only the name of the upload file won't pass to the process.php page. Any help much appreciated. Prob just some silly mistake that i made but i can't for the life of me see it. form <form enctype="multipart/form-data" action="process.php" method="POST" name="books" title="Santa_Book"> <img src="images/book/Enter_your_details.png" width="400" height="60" /><br /> <ul id="inline_list"> <input type="text" name="first_name" id="first_name" value="Text to be displayed here" onfocus="if(this.value==this.defaultValue)this.value='';" onblur="if(this.value=='')this.value=this.defaultValue;"/> <label for="sur_name" class="inside">Name</label> <input name="sur_name" type="text" id="sur_name" class="inside" /> <label for="sname">Surname</label> <br /> Sex <select name="sex" id="sex"> <option selected="selected">Please Select....</option> <option value="girl">Girl</option> <option value="boy">Boy</option> </select> <label for="age">Age</label> <input type="text" name="age" id="age" /> <br /> <label for="house_no">House No.</label> <input type="text" name="house_no" id="house_no" /> <br /> <label for="street">Street Name</label> <input type="text" name="street" id="street" /> <br /> <label for="town">Town</label> <input type="text" name="town" id="town" /> <br /> <br /> <select name="bscf1" id="bscf1"> <option selected="selected">Please Select...</option> <option value="Brother1">Brother</option> <option value="Sister1">Sister</option> <option value="Cousin1">Cousin</option> <option value="Friend1">Friend</option> </select> <label for="bscf_name1">Friend / Sibling</label> <input type="text" name="bscf_name1" id="bscf_name1" /> <br /> <select name="bscf2" id="bscf2"> <option>Please Select...</option> <option value="Brother2">Brother</option> <option value="Sister2">Sister</option> <option value="Cousin2">Cousin</option> <option value="Friend2">Friend</option> </select> <label for="bscf_name2">Friend / Sibling</label> <input type="text" name="bscf_name2" id="bscf_name2" /> <br /> <label for="from_name">This book is from...</label> <input type="text" name="from_name" id="from_name" /> <br /> <input name="uploadedfile" type="file" id="uploadedfile" value="Upload Image" /> <br /> </ul> <br /> <input type="submit" value="Continue" /> </form> process.php page <?php // Database connect $con = mysql_connect("mysql1.myhost.ie","admin_book","root123"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("book_test", $con); //Parse Values from Coupon.php Form $first_name = mysql_real_escape_string(trim($_POST['first_name'])); $sur_name = mysql_real_escape_string(trim($_POST['sur_name'])); $sex = mysql_real_escape_string(trim($_POST['sex'])); $age = mysql_real_escape_string(trim($_POST['age'])); $house_no = mysql_real_escape_string(trim($_POST['house_no'])); $street = mysql_real_escape_string(trim($_POST['street'])); $town = mysql_real_escape_string(trim($_POST['town'])); $bscf1 = mysql_real_escape_string(trim($_POST['bscf1'])); $bscf_name1 = mysql_real_escape_string(trim($_POST['bscf_name1'])); $bscf2 = mysql_real_escape_string(trim($_POST['bscf2'])); $bscf_name2 = mysql_real_escape_string(trim($_POST['bscf_name2'])); $from_name = mysql_real_escape_string(trim($_POST['from_name'])); $uploadedfile = mysql_real_escape_string(trim($_POST['name'])); if ($sex == 'girl') { $his_her = 'her'; } else { $his_her = 'his'; } if ($sex == 'girl') { $him_her = 'her'; } else { $him_her = 'his'; } $sql="INSERT INTO details (first_name, sur_name, sex, age, house_no, street, town, bscf1, bscf_name1, andy, bscf2, bscf_name2, his_her, him_her, from_name, uploadedfile) VALUES ('$first_name','$sur_name','$sex','$age','$house_no','$street','$town','$bscf1','$bscf_name1','and','$bscf2','$bscf_name2','$his_her','$him_her','$from_name','$uploadedfile')"; // Where the file is going to be placed $target_path = "uploads/"; /* Add the original filename to our target path. Result is "uploads/filename.extension" */ $target_path = $target_path . basename( $_FILES['uploadedfile']['name']); $target_path = "uploads/"; $target_path = $target_path . basename( $_FILES['uploadedfile']['name']); if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) { echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded"; } else{ echo "There was an error uploading the file, please try again!"; } echo 'Thank you '. $first_name . ' for entering your details bro.<br />'; echo 'surname is : '. $sur_name . '.<br />'; echo 'sex is : '. $sex . '.<br />'; echo 'age is: '. $age . ' .<br />'; echo 'bscf friend 1 is : '. $bscf1 . '.<br />'; echo 'bscf name 1 is : '. $bscf_name1 . '.<br />'; echo 'bscf friend 2 is : '. $bscf2 . '.<br />'; echo 'bscf name 2 is : '. $bscf_name2 . '.<br />'; echo 'his_her is : '. $his_her . ' .<br />'; echo 'him_her is : '. $him_her . '.<br />'; echo 'From Name is : '. $from_name . '.<br />'; echo 'Uploaded file is : '. $uploadedfile . '.<br />'; if (!mysql_query($sql)) { die('Error: ' . mysql_error()); } ?>
  12. ok someone said that this is far too complicated so i've tried it this way : form page <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>Digital Scribe Books</title> <link href="style.css" rel="stylesheet" type="text/css" /> <script type="text/javascript"> function MM_preloadImages() { //v3.0 var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array(); var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++) if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}} } function MM_swapImgRestore() { //v3.0 var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc; } function MM_findObj(n, d) { //v4.01 var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) { d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);} if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n]; for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); if(!x && d.getElementById) x=d.getElementById(n); return x; } function MM_swapImage() { //v3.0 var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3) if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];} } </script> </head> <body onload="MM_preloadImages('images/buttons/home_over.png','images/buttons/books_over.png','images/buttons/cards_over.png','images/buttons/letters_over.png')"> <div id="snow"> <div id="wrapper"> <div id="header"> <div id="logo"><img src="images/digital_scripe.png" width="218" height="91" /></div> <div id="menu"><a href="index.html" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Home','','images/buttons/home_over.png',1)"><img src="images/buttons/home_act.png" name="Home" width="131" height="132" border="0" id="Home" /></a><a href="#" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Books','','images/buttons/books_over.png',1)"><img src="images/buttons/books_act.png" name="Books" width="131" height="132" border="0" id="Books" /></a><a href="cards.html" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Cards','','images/buttons/cards_over.png',1)"><img src="images/buttons/cards_act.png" name="Cards" width="131" height="132" border="0" id="Cards" /></a><a href="letters.html" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Letters','','images/buttons/letters_over.png',1)"><img src="images/buttons/letters_act.png" name="Letters" width="131" height="132" border="0" id="Letters" /></a></div> </div> <div id="content"> <div id="info_bar"> <p>Send a personalised Christmas Card this year<br /> <img src="images/cards/SampleCard.png" width="120" height="104" /><br /> Available in packs of 10 or 20 from € including envelopes, p&p.</p> <p>Simply choose the style you would like on the inside of the card.</p> <p>Choose which pack you would like.<br /> </p> <p>Send us your drawing </p> <p>Your cards will be in the post with in 2-3 working days.</p> </div> <form enctype="multipart/form-data" action="process.php" method="POST" name="books" title="Santa_Book"> <img src="images/book/Enter_your_details.png" width="400" height="60" /><br /> <ul id="inline_list"> <input type="text" name="first_name" id="first_name" value="Text to be displayed here" onfocus="if(this.value==this.defaultValue)this.value='';" onblur="if(this.value=='')this.value=this.defaultValue;"/> <label for="sur_name" class="inside">Name</label> <input name="sur_name" type="text" id="sur_name" class="inside" /> <label for="sname">Surname</label> <br /> Sex <select name="sex" id="sex"> <option selected="selected">Please Select....</option> <option value="girl">Girl</option> <option value="boy">Boy</option> </select> <label for="age">Age</label> <input type="text" name="age" id="age" /> <br /> <label for="house_no">House No.</label> <input type="text" name="house_no" id="house_no" /> <br /> <label for="street">Street Name</label> <input type="text" name="street" id="street" /> <br /> <label for="town">Town</label> <input type="text" name="town" id="town" /> <br /> <br /> <select name="bro_sis_cous_friend1" id="bro_sis_cous_friend1"> <option selected="selected">Please Select...</option> <option value="Brother1">Brother</option> <option value="Sister1">Sister</option> <option value="Cousin1">Cousin</option> <option value="Friend1">Friend</option> </select> <label for="bscf_name1">Friend / Sibling</label> <input type="text" name="bscf_name1" id="bscf_name1" /> <br /> <select name="Friend / Sibling"> <option>Please Select...</option> <option value="Brother2">Brother</option> <option value="Sister2">Sister</option> <option value="Cousin2">Cousin</option> <option value="Friend2">Friend</option> </select> <label for="bscf_name2">Friend / Sibling</label> <input type="text" name="bscf_name2" id="bscf_name2" /> <br /> <label for="from_name">This book is from...</label> <input type="text" name="from_name" id="from_name" /> <br /> <input name="uploadedfile" type="file" id="uploadedfile" value="Upload Image" /> <br /> </ul> <br /> <input type="submit" value="Continue" /> </form> </div> <div id="footer" class="clear"><div id="sign"><div id="sign_text">Personalised<br /> Books</div> </div></div> </div></div> </body> </html> process.php page <?php // Database connect $con = mysql_connect("mysql1.myhost.ie","admin_book","root123"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("book_test", $con); //Parse Values from Coupon.php Form $first_name = mysql_real_escape_string(trim($_POST['first_name'])); $sur_name = mysql_real_escape_string(trim($_POST['sur_name'])); $sex = mysql_real_escape_string(trim($_POST['sex'])); $age = mysql_real_escape_string(trim($_POST['age'])); $house_no = mysql_real_escape_string(trim($_POST['house_no'])); $street = mysql_real_escape_string(trim($_POST['street'])); $town = mysql_real_escape_string(trim($_POST['town'])); $bro_sis_cous_friend1 = mysql_real_escape_string(trim($_POST['bro_sis_cous_friend1'])); $bscf_name1 = mysql_real_escape_string(trim($_POST['bscf_name1'])); $bro_sis_cous_friend2 = mysql_real_escape_string(trim($_POST['bro_sis_cous_friend2'])); $bscf_name2 = mysql_real_escape_string(trim($_POST['bscf_name2'])); $from_name = mysql_real_escape_string(trim($_POST['from_name'])); $photo = mysql_real_escape_string(trim($_POST['uploadedfile'])); if ($sex == 'girl') { $his_her = 'her'; } else { $his_her = 'his'; } if ($sex == 'girl') { $him_her = 'her'; } else { $him_her = 'his'; } $sql="INSERT INTO details (first_name, sur_name, sex, age, house_no, street, town, bro_sis_cous_friend1, bscf_name1, andy, bro_sis_cous_friend2, bscf_name2, his_her, him_her, from_name, photo) VALUES ('$first_name','$sur_name','$sex','$age','$house_no','$street','$town','$bro_sis_cous_friend1','$bscf_name1','and','$bro_sis_cous_friend2','$bscf_name2','$his_her','$him_her','$from_name','$photo')"; // Where the file is going to be placed $target_path = "uploads/"; /* Add the original filename to our target path. Result is "uploads/filename.extension" */ $target_path = $target_path . basename( $_FILES['uploadedfile']['name']); $target_path = "uploads/"; $target_path = $target_path . basename( $_FILES['uploadedfile']['name']); if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) { echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded"; } else{ echo "There was an error uploading the file, please try again!"; } echo 'Thank you '. $first_name . ' for entering your details bro.<br />'; echo 'surname is : '. $photo . '.<br />'; echo 'sex is : '. $sex . '.<br />'; echo 'age is: '. $age . ' .<br />'; echo 'bscf friend 1 is : '. $bro_sis_cous_friend1 . '.<br />'; echo 'his_her is : '. $his_her . ' .<br />'; echo 'him_her is : '. $him_her . '.<br />'; if (!mysql_query($sql)) { die('Error: ' . mysql_error()); } ?> when i run just the upload code it works fine, but when i add it to the rest of the process.php page it stops working. I output i get it: There was an error uploading the file, please try again!Thank you witch for entering your details bro. surname is : . sex is : girl. age is: 55 . bscf friend 1 is : Sister1. his_her is : her . him_her is : her. I think i just have the code in the wrong order but well...... thanks MsKazza
  13. id doesn't actually give any specific error message just the error function that is included in the code : // make an error handler which will be used if the upload fails function error($error, $location, $seconds = 5) { header("Refresh: $seconds; URL=\"$location\""); echo '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"'."\n". '"http://www.w3.org/TR/html4/strict.dtd">'."\n\n". '<html lang="en">'."\n". ' <head>'."\n". ' <meta http-equiv="content-type" content="text/html; charset=iso-8859-1">'."\n\n". ' <link rel="stylesheet" type="text/css" href="stylesheet.css">'."\n\n". ' <title>Upload error</title>'."\n\n". ' </head>'."\n\n". ' <body>'."\n\n". ' <div id="Upload">'."\n\n". ' <h1>Upload failure</h1>'."\n\n". ' <p>An error has occured: '."\n\n". ' <span class="red">' . $error . '...</span>'."\n\n". ' The upload form is reloading</p>'."\n\n". ' </div>'."\n\n". '</html>'; exit; } // end error handler
  14. Yeah i wish it was that easy, thanks for catching that but its still in the error loop.
  15. Hi was hoping someone can tell me where i've gone wrong. its a form for the user to upload a picture and then goes to the process.php page, however it doesn't seem to work, it calls the error and goes back to books.php (form page) books.php <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>Digital Scribe Books</title> <link href="style.css" rel="stylesheet" type="text/css" /> <script type="text/javascript"> function MM_preloadImages() { //v3.0 var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array(); var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++) if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}} } function MM_swapImgRestore() { //v3.0 var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc; } function MM_findObj(n, d) { //v4.01 var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) { d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);} if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n]; for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); if(!x && d.getElementById) x=d.getElementById(n); return x; } function MM_swapImage() { //v3.0 var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3) if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];} } </script> <?php $directory_self = str_replace(basename($_SERVER['PHP_SELF']), '', $_SERVER['PHP_SELF']); // make a note of the location of the upload handler script $uploadHandler = 'http://' . $_SERVER['HTTP_HOST'] . $directory_self . 'process.php'; ?> </head> <body onload="MM_preloadImages('images/buttons/home_over.png','images/buttons/books_over.png','images/buttons/cards_over.png','images/buttons/letters_over.png')"> <div id="snow"> <div id="wrapper"> <div id="header"> <div id="logo"><img src="images/digital_scripe.png" width="218" height="91" /></div> <div id="menu"><a href="index.html" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Home','','images/buttons/home_over.png',1)"><img src="images/buttons/home_act.png" name="Home" width="131" height="132" border="0" id="Home" /></a><a href="#" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Books','','images/buttons/books_over.png',1)"><img src="images/buttons/books_act.png" name="Books" width="131" height="132" border="0" id="Books" /></a><a href="cards.html" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Cards','','images/buttons/cards_over.png',1)"><img src="images/buttons/cards_act.png" name="Cards" width="131" height="132" border="0" id="Cards" /></a><a href="letters.html" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Letters','','images/buttons/letters_over.png',1)"><img src="images/buttons/letters_act.png" name="Letters" width="131" height="132" border="0" id="Letters" /></a></div> </div> <div id="content"> <div id="info_bar"> <p>Send a personalised Christmas Card this year<br /> <img src="images/cards/SampleCard.png" width="120" height="104" /><br /> Available in packs of 10 or 20 from € including envelopes, p&p.</p> <p>Simply choose the style you would like on the inside of the card.</p> <p>Choose which pack you would like.<br /> </p> <p>Send us your drawing </p> <p>Your cards will be in the post with in 2-3 working days.</p> </div> <form action="<?php echo $uploadHandler ?>" method="post" enctype="multipart/form-data" name="books" title="Santa_Book"> <img src="images/book/Enter_your_details.png" width="400" height="60" /><br /> <ul id="inline_list"> <input type="text" name="first_name" id="first_name" value="Text to be displayed here" onfocus="if(this.value==this.defaultValue)this.value='';" onblur="if(this.value=='')this.value=this.defaultValue;"/> <label for="sur_name" class="inside">Name</label> <input name="sur_name" type="text" id="sur_name" class="inside" /> <label for="sname">Surname</label> <br /> Sex <select name="sex" id="sex"> <option selected="selected">Please Select....</option> <option value="girl">Girl</option> <option value="boy">Boy</option> </select> <label for="age">Age</label> <input type="text" name="age" id="age" /> <br /> <label for="house_no">House No.</label> <input type="text" name="house_no" id="house_no" /> <br /> <label for="street">Street Name</label> <input type="text" name="street" id="street" /> <br /> <label for="town">Town</label> <input type="text" name="town" id="town" /> <br /> <br /> <select name="bro_sis_cous_friend1" id="bro_sis_cous_friend1"> <option selected="selected">Please Select...</option> <option value="Brother1">Brother</option> <option value="Sister1">Sister</option> <option value="Cousin1">Cousin</option> <option value="Friend1">Friend</option> </select> <label for="bscf_name1">Friend / Sibling</label> <input type="text" name="bscf_name1" id="bscf_name1" /> <br /> <select name="Friend / Sibling"> <option>Please Select...</option> <option value="Brother2">Brother</option> <option value="Sister2">Sister</option> <option value="Cousin2">Cousin</option> <option value="Friend2">Friend</option> </select> <label for="bscf_name2">Friend / Sibling</label> <input type="text" name="bscf_name2" id="bscf_name2" /> <br /> <label for="from_name">This book is from...</label> <input type="text" name="from_name" id="from_name" /> <br /> <input name="photo" type="file" id="photo" value="Upload Image" /> <br /> </ul> <br /> <button type="submit" name="card_submit" id="submit_button">Continue</button> </form> </div> <div id="footer" class="clear"><div id="sign"><div id="sign_text">Personalised<br /> Books</div> </div></div> </div></div> </body> </html> process.php page <?php // Database connect $con = mysql_connect("mysql1.myhost.ie","admin_book","root123"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("book_test", $con); //Parse Values from Coupon.php Form $first_name = mysql_real_escape_string(trim($_POST['first_name'])); $sur_name = mysql_real_escape_string(trim($_POST['sur_name'])); $sex = mysql_real_escape_string(trim($_POST['sex'])); $age = mysql_real_escape_string(trim($_POST['age'])); $house_no = mysql_real_escape_string(trim($_POST['house_no'])); $street = mysql_real_escape_string(trim($_POST['street'])); $town = mysql_real_escape_string(trim($_POST['town'])); $bro_sis_cous_friend1 = mysql_real_escape_string(trim($_POST['bro_sis_cous_friend1'])); $bscf_name1 = mysql_real_escape_string(trim($_POST['bscf_name1'])); $bro_sis_cous_friend2 = mysql_real_escape_string(trim($_POST['bro_sis_cous_friend2'])); $bscf_name2 = mysql_real_escape_string(trim($_POST['bscf_name2'])); $from_name = mysql_real_escape_string(trim($_POST['from_name'])); $photo_link = mysql_real_escape_string(trim($_POST['photo_link'])); if ($sex == 'girl') { $his_her = 'her'; } else { $his_her = 'his'; } if ($sex == 'girl') { $him_her = 'her'; } else { $him_her = 'his'; } // make a note of the directory that will recieve the uploaded files $uploadsDirectory = 'images/photos'; // make a note of the location of the upload form in case we need it $uploadForm = 'books.php'; // make a note of the location of the success page $uploadSuccess = 'thanks.php'; // Now let's deal with the upload // possible PHP upload errors $errors = array(1 => 'php.ini max file size exceeded', 2 => 'html form max file size exceeded', 3 => 'file upload was only partial', 4 => 'no file was attached'); // check the upload form was actually submitted else print form isset($_POST['submit']) or error('the upload form is neaded', $uploadForm); // check for standard uploading errors ($_FILES[$fieldname]['error'] == 0) or error($errors[$_FILES[$fieldname]['error']], $uploadForm); // check that the file we are working on really was an HTTP upload @is_uploaded_file($_FILES[$fieldname]['tmp_name']) or error('not an HTTP upload', $uploadForm); // validation... since this is an image upload script we // should run a check to make sure the upload is an image @getimagesize($_FILES[$fieldname]['tmp_name']) or error('only image uploads are allowed', $uploadForm); // make a unique filename for the uploaded file and check it is // not taken... if it is keep trying until we find a vacant one $now = time(); while(file_exists($uploadFilename = $uploadsDirectory.$now.'-'.$_FILES[$photo_link]['name'])) { $now++; } // now let's move the file to its final and allocate it with the new filename @move_uploaded_file($_FILES[$photo_link]['tmp_name'], $uploadFilename) or error('receiving directory insuffiecient permission', $uploadForm); // make an error handler which will be used if the upload fails function error($error, $location, $seconds = 5) { header("Refresh: $seconds; URL=\"$location\""); echo '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"'."\n". '"http://www.w3.org/TR/html4/strict.dtd">'."\n\n". '<html lang="en">'."\n". ' <head>'."\n". ' <meta http-equiv="content-type" content="text/html; charset=iso-8859-1">'."\n\n". ' <link rel="stylesheet" type="text/css" href="stylesheet.css">'."\n\n". ' <title>Upload error</title>'."\n\n". ' </head>'."\n\n". ' <body>'."\n\n". ' <div id="Upload">'."\n\n". ' <h1>Upload failure</h1>'."\n\n". ' <p>An error has occured: '."\n\n". ' <span class="red">' . $error . '...</span>'."\n\n". ' The upload form is reloading</p>'."\n\n". ' </div>'."\n\n". '</html>'; exit; } // end error handler $sql="INSERT INTO details (first_name, sur_name, sex, age, house_no, street, town, bro_sis_cous_friend1, bscf_name1, andy, bro_sis_cous_friend2, bscf_name2, his_her, him_her, from_name, photo_link) VALUES ('$first_name','$sur_name','$sex','$age','$house_no','$street','$town','$bro_sis_cous_friend1','$bscf_name1','and','$bro_sis_cous_friend2','$bscf_name2','$his_her','$him_her','$from_name','$photo_link')"; echo 'Thank you '. $first_name . ' for entering your details bro.<br />'; echo 'surname is : '. $sur_name . '.<br />'; echo 'sex is : '. $sex . '.<br />'; echo 'age is: '. $age . ' .<br />'; echo 'bscf friend 1 is : '. $bro_sis_cous_friend1 . '.<br />'; echo 'his_her is : '. $his_her . ' .<br />'; echo 'him_her is : '. $him_her . '.<br />'; if (!mysql_query($sql)) { die('Error: ' . mysql_error()); } header("Location: thanks.php"); ?> pls pls help i'm soooo stuck lol MsKazza
  16. I created a form where people will upload their photos and then the form gets submitted to a process.php page. Before i added the photo upload script, it inserted the record and the whole process.php page worked great. Now i have added the photo upload script (Pure PHP Upload 2 by DMXZone.com) and the form action has changed and the values are not posting correctly to the process.php page. I have used this script lots of times before but always with the dreamweaver insert record, never using code i wrote myself. The Photos are uploading and a record is being created in the database however the record is emtpy. <?php require_once('ScriptLibrary/incPureUpload.php'); ?> <?php // Pure PHP Upload 2.1.3 if (isset($HTTP_GET_VARS['GP_upload'])) { $ppu = new pureFileUpload(); $ppu->path = "images/photos"; $ppu->extensions = ""; $ppu->formName = "books"; $ppu->storeType = "file"; $ppu->sizeLimit = ""; $ppu->nameConflict = "uniq"; $ppu->requireUpload = "true"; $ppu->minWidth = ""; $ppu->minHeight = ""; $ppu->maxWidth = ""; $ppu->maxHeight = ""; $ppu->saveWidth = ""; $ppu->saveHeight = ""; $ppu->timeout = "600"; $ppu->progressBar = "blueFlashProgress.htm"; $ppu->progressWidth = "500"; $ppu->progressHeight = "300"; $ppu->checkVersion("2.1.3"); $ppu->doUpload(); $uploadGoTo = "process.php"; if (isset($HTTP_SERVER_VARS['QUERY_STRING'])) { $uploadGoTo .= (strpos($uploadGoTo, '?')) ? "&" : "?"; $uploadGoTo .= $HTTP_SERVER_VARS['QUERY_STRING']; } header(sprintf("Location: %s", $uploadGoTo)); } $GP_uploadAction = $HTTP_SERVER_VARS['PHP_SELF']; if (isset($HTTP_SERVER_VARS['QUERY_STRING'])) { if (!eregi("GP_upload=true", $HTTP_SERVER_VARS['QUERY_STRING'])) { $GP_uploadAction .= "?".$HTTP_SERVER_VARS['QUERY_STRING']."&GP_upload=true"; } else { $GP_uploadAction .= "?".$HTTP_SERVER_VARS['QUERY_STRING']; } } else { $GP_uploadAction .= "?"."GP_upload=true"; } if (isset($editFormAction)) { if (isset($HTTP_SERVER_VARS['QUERY_STRING'])) { if (!eregi("GP_upload=true", $HTTP_SERVER_VARS['QUERY_STRING'])) { $editFormAction .= "&GP_upload=true"; } } else { $editFormAction .= "?GP_upload=true"; } } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>Digital Scribe Books</title> <link href="style.css" rel="stylesheet" type="text/css" /> <script type="text/javascript"> function MM_preloadImages() { //v3.0 var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array(); var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++) if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}} } function MM_swapImgRestore() { //v3.0 var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc; } function MM_findObj(n, d) { //v4.01 var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) { d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);} if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n]; for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); if(!x && d.getElementById) x=d.getElementById(n); return x; } function MM_swapImage() { //v3.0 var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3) if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];} } </script> <script language='javascript' src='ScriptLibrary/incPureUpload.js'></script> </head> <body onload="MM_preloadImages('images/buttons/home_over.png','images/buttons/books_over.png','images/buttons/cards_over.png','images/buttons/letters_over.png')"> <div id="snow"> <div id="wrapper"> <div id="header"> <div id="logo"><img src="images/digital_scripe.png" width="218" height="91" /></div> <div id="menu"><a href="index.html" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Home','','images/buttons/home_over.png',1)"><img src="images/buttons/home_act.png" name="Home" width="131" height="132" border="0" id="Home" /></a><a href="#" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Books','','images/buttons/books_over.png',1)"><img src="images/buttons/books_act.png" name="Books" width="131" height="132" border="0" id="Books" /></a><a href="cards.html" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Cards','','images/buttons/cards_over.png',1)"><img src="images/buttons/cards_act.png" name="Cards" width="131" height="132" border="0" id="Cards" /></a><a href="letters.html" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Letters','','images/buttons/letters_over.png',1)"><img src="images/buttons/letters_act.png" name="Letters" width="131" height="132" border="0" id="Letters" /></a></div> </div> <div id="content"> <div id="info_bar"> <p>Send a personalised Christmas Card this year<br /> <img src="images/cards/SampleCard.png" width="120" height="104" /><br /> Available in packs of 10 or 20 from € including envelopes, p&p.</p> <p>Simply choose the style you would like on the inside of the card.</p> <p>Choose which pack you would like.<br /> </p> <p>Send us your drawing </p> <p>Your cards will be in the post with in 2-3 working days.</p> </div> <form action="<?php echo $GP_uploadAction; ?>" method="post" enctype="multipart/form-data" name="books" title="Santa_Book" onsubmit="checkFileUpload(this,'',true,'','','','','','','');showProgressWindow('blueFlashProgress.htm',500,300);return document.MM_returnValue"> <img src="images/book/Enter_your_details.png" width="400" height="60" /><br /> <ul id="inline_list"> <input type="text" name="first_name" id="first_name" value="Text to be displayed here" onfocus="if(this.value==this.defaultValue)this.value='';" onblur="if(this.value=='')this.value=this.defaultValue;"/> <label for="sur_name" class="inside">Name</label> <input name="sur_name" type="text" id="sur_name" class="inside" /> <label for="sname">Surname</label> <br /> Sex <select name="sex" id="sex"> <option selected="selected">Please Select....</option> <option value="girl">Girl</option> <option value="boy">Boy</option> </select> <label for="age">Age</label> <input type="text" name="age" id="age" /> <br /> <label for="house_no">House No.</label> <input type="text" name="house_no" id="house_no" /> <br /> <label for="street">Street Name</label> <input type="text" name="street" id="street" /> <br /> <label for="town">Town</label> <input type="text" name="town" id="town" /> <br /> <br /> <select name="bro_sis_cous_friend1" id="bro_sis_cous_friend1"> <option selected="selected">Please Select...</option> <option value="Brother1">Brother</option> <option value="Sister1">Sister</option> <option value="Cousin1">Cousin</option> <option value="Friend1">Friend</option> </select> <label for="bscf_name1">Friend / Sibling</label> <input type="text" name="bscf_name1" id="bscf_name1" /> <br /> <select name="Friend / Sibling"> <option>Please Select...</option> <option value="Brother2">Brother</option> <option value="Sister2">Sister</option> <option value="Cousin2">Cousin</option> <option value="Friend2">Friend</option> </select> <label for="bscf_name2">Friend / Sibling</label> <input type="text" name="bscf_name2" id="bscf_name2" /> <br /> <label for="from_name">This book is from...</label> <input type="text" name="from_name" id="from_name" /> <br /> <input name="photo" type="file" id="photo" onchange="checkOneFileUpload(this,'',true,'','','','','','','')" value="Upload Image" /> <br /> </ul> <br /> <button type="submit" name="card_submit" id="submit_button">Continue</button> </form> </div> <div id="footer" class="clear"><div id="sign"><div id="sign_text">Personalised<br /> Books</div> </div></div> </div></div> </body> </html> The dmxzone people said to change the method to get so i did and used : $first_name = mysql_real_escape_string(trim($_GET['first_name'])); to retrieve the records, still no joy, in fact it doesn't even go to the process.php page when i change it to get Any help much appreciated. Thanks, MsKazza
  17. thank you for your help, i've managed to do it, i just changed it in the database to andy lol all help much appreciated.
  18. yeah i managed to get it connected, and then got the following : Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'and, bro_sis_cous_friend2, bscf_name2, his_her, him_her, from_name, photo_link) ' at line 1 so how can i get it to insert 'and' into the database? thanks
  19. <?php require_once('Connections/book.php'); // Database connect //Parse Values from Coupon.php Form $first_name = mysql_real_escape_string(trim($_POST['first_name'])); $sur_name = mysql_real_escape_string(trim($_POST['sur_name'])); $sex = mysql_real_escape_string(trim($_POST['sex'])); $age = mysql_real_escape_string(trim($_POST['age'])); $house_no = mysql_real_escape_string(trim($_POST['house_no'])); $street = mysql_real_escape_string(trim($_POST['street'])); $town = mysql_real_escape_string(trim($_POST['town'])); $bro_sis_cous_friend1 = mysql_real_escape_string(trim($_POST['bro_sis_cous_friend1'])); $bscf_name1 = mysql_real_escape_string(trim($_POST['bscf_name1'])); $bro_sis_cous_friend2 = mysql_real_escape_string(trim($_POST['bro_sis_cous_friend2'])); $bscf_name2 = mysql_real_escape_string(trim($_POST['bscf_name2'])); $from_name = mysql_real_escape_string(trim($_POST['from_name'])); $photo_link = mysql_real_escape_string(trim($_POST['photo_link'])); if ($sex == 'girl') { $his_her = 'her'; } else { $his_her = 'his'; } if ($sex == 'girl') { $him_her = 'her'; } else { $him_her = 'his'; } $sql="INSERT INTO details (first_name, sur_name, sex, age, house_no, street, town, bro_sis_cous_friend1, bscf_name1, and, bro_sis_cous_friend2, bscf_name2, his_her, him_her, from_name, photo_link) VALUES ('$first_name','$sur_name','$sex','$age','$house_no','$street','$town','$bro_sis_cous_friend1','$bscf_name1','and','$bro_sis_cous_friend2','$bscf_name2','$his_her','$him_her','$from_name','$photo_link')"; echo 'Thank you '. $first_name . ' for entering your details.<br />'; echo 'surname is : '. $sur_name . '.<br />'; echo 'sex is : '. $sex . '.<br />'; echo 'age is: '. $age . ' .<br />'; echo 'bscf friend 1 is : '. $bro_sis_cous_friend1 . '.<br />'; echo 'his_her is : '. $his_her . ' .<br />'; echo 'him_her is : '. $him_her . '.<br />'; if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); } echo "1 record added"; ?>
  20. Hi all I'm working on a form, i've gotten all the values from the form to the process.php page and it is assigning the correct variables but i can't get it to insert into the database, i know the connection info is correct as i have other page connecting and i can create a recordset on that page. i guess my sql is wrong any help much appreciated. the following is the sql from the database and attached is the process.php page. -- Table structure for table `details` -- CREATE TABLE `details` ( `id` int(6) NOT NULL auto_increment, `first_name` varchar(20) NOT NULL, `sur_name` varchar(20) NOT NULL, `sex` varchar(6) NOT NULL, `age` varchar(3) NOT NULL, `house_no` varchar(5) NOT NULL, `street` varchar(150) NOT NULL, `town` varchar(50) NOT NULL, `bro_sis_cous_friend1` varchar(50) default NULL, `bscf_name1` varchar(150) default NULL, `and` varchar(4) NOT NULL, `bro_sis_cous_friend2` varchar(50) default NULL, `bscf_name2` varchar(150) default NULL, `his_her` varchar(4) default NULL, `him_her` varchar(4) default NULL, `from_name` varchar(150) NOT NULL, `photo_link` varchar(255) default NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=36 ; [attachment deleted by admin]
  21. typical i've found it thanks, must be having brain freeze today or something, declared variables in common.php, required it in header.php and then echo'd the variables i wanted. thanks for reply though.
  22. how do i make one form field insert it's value into several mysql columns of the same record? They want it put in the second to last, third to last and forth to last fields
  23. ok, the site is for a company that want to make special children's xmas books. the user enters basic info into the form, their names, the childs name, the sex of the child, and contact info. However in the database there are the fields mentioned above. Want to know if it's possible to have the form if the user selects for instance that the child is a boy, insert into more than one column the word he or his and likewise if they choose girl, she or hers. Hope that makes more sense, looking at it now though i've a feeling though that this might be more a php question possibly. Thanks, MsKazza
×
×
  • 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.