Jump to content

jay_bo

Members
  • Posts

    61
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

jay_bo's Achievements

Member

Member (2/5)

0

Reputation

  1. Hey, i am having trouble with a email script... I can't remember how to include variables in an email message, please could someone rejog my memory, heres my code <?php $date = $_POST["G-Preferred_Start_date"]; $nights = $_POST["nights"]; $adults = $_POST["adults"]; $children = $_POST["children"]; $name = $_POST["name"]; $email = $_POST["email"]; $telephone = $_POST["telephone"]; $to = "myeamil@email.com"; $subject = "TAccomodation Enquiry"; $message = "Hello! This is an email from the delton website \n".$date.""; $from = "someonelse@example.com"; $headers = "From: $from"; mail($to,$subject,$message,$headers); echo "Mail Sent."; ?>
  2. How could i test it out?
  3. I have created a shopping cart using php from scratch and linked it to paypal for the transactions. I was wondering whether i would have any security threats or risks seems that i have self built it. Many thanks
  4. Okay i have a shopping cart which has the ability to add and remove items in the cart, which is done by javascript..as seen below function del(pid){ if(confirm('Do you really mean to delete this item')){ document.form1.pid.value=pid; document.form1.command.value='delete'; document.form1.submit(); } } function update_cart(){ document.form1.command.value='update'; document.form1.submit(); } It use to work fine when i add <form name="form1" method="POST"> but i recently changed it to the code below, so that i can link it to paypal. <form name="form1" action="https://www.sandbox.paypal.com/uk/cgi-bin/webscr" method="POST"> Since i add this when i click to update an item it doesn't update, it just submits the form.....Now i know this has something to do with the javascript line.... document.form1.submit(); Is there anyway that i could get it to refresh the page?
  5. Okay i have a shopping cart which has the ability to add and remove items in the cart, which is done by javascript..as seen below function del(pid){ if(confirm('Do you really mean to delete this item')){ document.form1.pid.value=pid; document.form1.command.value='delete'; document.form1.submit(); } } function update_cart(){ document.form1.command.value='update'; document.form1.submit(); } It use to work fine when i add <form name="form1" method="POST"> but i recently changed it to the code below, so that i can link it to paypal. <form name="form1" action="https://www.sandbox.paypal.com/uk/cgi-bin/webscr" method="POST"> Since i add this when i click to update an item it doesn't update, it just submits the form.....Now i know this has something to do with the javascript line.... document.form1.submit(); Is there anyway that i could get it to refresh the page?
  6. jay_bo

    PayPal

    Nice one, it worked Many thanks
  7. jay_bo

    PayPal

    Hey, I have managed to link my shopping cart to paypal...However i can't get the paypal page to display in UK sterling instead of US dollars...Ive searched the paypal website and documentation and i have added echo '<input type="hidden" name="currency_code" value="{$currency_iso_GBP}">'; And it still doesn't work, any ideas? Thanks
  8. I am trying to save a price of a product in my table and i have inserted 5.10...how can i stop it from just display 5.1? Thanks
  9. Right okay, The code below pulls data from a mysql table and it displays the products available to purchase... I have done a while loop to display all the products and i have also done another while loop so that i can use a drop down box to select Small, Medium and Large which each have the vaule of its product id...However when i go to purchase the first product on the page and I click on the button to add to cart, it adds the last product on the page instead...heres my code... echo'<form name="form1" method="post" action="myscript.php">'; $cat=$_GET['cat']; if ($cat!="") { $result=mysql_query("SELECT * FROM products WHERE cat_id=$cat"); while($row=mysql_fetch_array($result)){ echo'<input type="hidden" name="command" />'; echo '<br />'; echo '<div id="item_container">'; echo '<div id="item_picture"><a href="'.$row["picture_large"].'" class="thickbox" rel="album" ><img src="'.$row["picture"].'" border="0" alt="'.$row["image_alt"].'"></a></div>'; echo '<div id="item_title"><h2>'.$row["name"].'</h2></div>'; echo '<div id="item_text"><p>'.substr($row["description"], 0, 100).'</p><br /><br />'; $type=$row["type"]; echo '<select name="productid">'; $sql="SELECT * FROM products WHERE type=$type"; $result2 =mysql_query($sql); while ($row=mysql_fetch_assoc($result2)){ echo'<option value ='.$row["serial"].'>'.$row["price"].'</option>'; } echo '</select>'; echo '<br /><br/>'; echo '<input type="submit" value="Add to Cart"/></span>'; echo '</div>'; echo '<br />'; echo '<br />'; echo '</div>'; } } echo '</form>'; and on myscript.php all it does is outputs what the dropdown list was selected <?PHP include("includes/db.php"); $pid=$_POST['productid']; echo $pid; ?> Many thanks
  10. That is because all that code is on one php page. It doesn't matter if the code is all on one page, once it goes to the browser, the browser doesn't know what to do when the form submits if there's no form action or form method. You still need to do what leehanken suggests: <form name='form1' action='myscript.php' method='post'> Yes i see what you mean, tomorrow i will make the form post and copy the code onto a new page. Thanks for your help guys
  11. shall i post the whole page code on here?
  12. That is because all that code is on one php page.
  13. Thanks for getting back to me....Right i changed and messed about with the coding my self and here it is $result=mysql_query("SELECT * FROM products WHERE cat_id=$cat"); while($row=mysql_fetch_array($result)){ echo'<form name="form1">'; echo'<input type="hidden" name="command" />'; echo '<br />'; echo '<div id="item_container">'; echo '<div id="item_picture"><a href="'.$row["picture_large"].'" class="thickbox" rel="album" ><img src="'.$row["picture"].'" border="0" alt="'.$row["image_alt"].'"></a></div>'; echo '<div id="item_title"><h2>'.$row["name"].'</h2></div>'; echo '<div id="item_text"><p>'.substr($row["description"], 0, 100).'</p><br /><br />'; echo '<select name="productid">'; $type=$row["type"]; $sql="SELECT * FROM products WHERE type=$type"; $result2 =mysql_query($sql); while ($row=mysql_fetch_assoc($result2)){ echo'<option value ='.$row["serial"].'>'.$row["price"].'</option>'; } echo '</select>'; echo '<input type="button" value="Add to Cart" onclick="addtocart('.$row["serial"].')"/></span>'; echo '<br /><br/>'; echo '</div>'; echo '<br />'; echo '<br />'; echo '</div>'; } } echo '</form>'; Which once the button is pressed goes to javascript.... <script language="javascript"> function addtocart(pid){ document.form1.productid.value=pid; document.form1.command.value='add'; document.form1.submit(); } </script> Which looks at form1 tag which i have added to the php code above and renamed the dropdown list as productid ^^ then the javascript code should go to.... if($_REQUEST['command']=='add' && $_REQUEST['productid']>0){ $pid=$_GET['productid']; addtocart($pid,1); header("location:shoppingcart.php"); exit(); } As i mentioned before that i had added the form1 tag to the php code and changed the dropdown list name, actually adds products to the checkout but however because it is looping it also adds other products... this is the url i see..... http://localhost%20Site/orderonline.php?command=&productid=98&command=&productid=99 If i changed it and got rid of product 2 so it looked like this http://localhost%20Site/orderonline.php?command=&productid=98 then it would add to the basket fine.........I just need it to stop adding the other products to the url and i know this is because i have added it to the loop so that the form1 tag is around every product that gets displayed. Thanks
  14. Ive just realised that it basicallys add my first product and what ever i have selected in the drop down list and then it also adds the product underneath and its first selected item... how can i stop it from adding the second product? For example, my url... http://localhost%20Site/orderonline.php?command=&productid=98&command=&productid=99 first product - command=&productid=98 second product - command=&productid=99 I need it just to contain the first product like ... http://localhost%20Site/orderonline.php?command=&productid=98 I think it is something to do with the while loop
×
×
  • 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.