Jump to content

Digiboy

Members
  • Posts

    29
  • Joined

  • Last visited

Digiboy's Achievements

Member

Member (2/5)

0

Reputation

  1. found it, it was $new_service_no = '0') it was changing value to 0 so my validation was wrong. Thank you all again.
  2. I added this to add-services form not product; this is for services (They both have same issue) Array ( [product_no] => 951554 [item_price] => 55.00 [add-product] => )
  3. this is what I get Array ( [service] => 847153 [item_price] => 4.00 [add-service] => )
  4. Thank you If I put exit; it doesnt execute rest of page and about the query, I need to have seperate forms so call to action only happens to one of them forms at same time Checked all, i dont have any cookies, and database column is varchar 200 Main issue is not php becuase when I echo $new_product_no = mysql_real_escape_string($_POST['product_no']); echo"$new_product_no"; My echo result is 0, it passes it as zero to insert query
  5. Hi guys, I have written this code to insert shopping items in a database but recently when user adds an item, item code is inserted as 0, I have also my php error on but still cant not figure out why and this happens to both add-product and service posts. It inserts everything else correctly except product or service no Any advise or help is appreciated <?php include_once('includes/header.php'); ?> <?php $get_car_reg = mysql_real_escape_string($_GET['car']); $get_car_reg = mb_strtoupper($get_car_reg); $get_invoice = mysql_real_escape_string($_GET['invoice']); if (isset($_POST['delete'])) { $delete_current_item = mysql_real_escape_string($_POST['delete_me']); $delete = mysql_query("DELETE FROM items WHERE id='$delete_current_item'"); header("Location:generate_invoice.php?car=$get_car_reg&invoice=$get_invoice"); } if (isset($_POST['sp'])) { $final_total = mysql_real_escape_string($_POST['final_total']); $final_discount = mysql_real_escape_string($_POST['final_discount']); $final_invoice_sub = mysql_real_escape_string($_POST['final_sub_total']); $final_vat = mysql_real_escape_string($_POST['final_vat']); $final_total = $final_total - $final_discount; $select_current = mysql_query("SELECT * FROM invoices WHERE invoice_no='$get_invoice'"); if (mysql_num_rows($select_current) >= 1) { $update = mysql_query("UPDATE invoices SET invoice_no='$get_invoice', sub_total='$final_invoice_sub', vat='$final_vat', total='$final_total', discount='$final_discount' WHERE invoice_no='$get_invoice'"); } else { $insert = mysql_query("INSERT INTO invoices (invoice_no, sub_total, vat, total, discount) VALUES ('$get_invoice','$final_invoice_sub','$final_vat','$final_total','$final_discount')"); } if ($insert || $update) { header("Location: print.php?car=$get_car_reg&invoice=$get_invoice"); } } ?> <h2>Invoice</h2> <h3>Car Reg: <?php echo"$get_car_reg"; ?></h3> <? if (empty($get_car_reg) || empty($get_invoice)) { header("Location: create-customer.php"); } else { if (isset($_POST['add-product'])) { $item_price = mysql_real_escape_string($_POST['item_price']); $new_product_no = mysql_real_escape_string($_POST['product_no']); if (empty($new_product_no) || $new_product_no = '0') { echo"<div class='alert alert-error'>You need to select an item</div>"; } else { $insert = mysql_query("INSERT INTO items (invoice_no, item_no, item_type, price) VALUES ('$get_invoice','$new_product_no','Product','$item_price')"); echo"$new_product_no is"; // header("Location:generate_invoice.php?car=$get_car_reg&invoice=$get_invoice"); } } else { if (isset($_POST['add-service'])) { $item_price = mysql_real_escape_string($_POST['item_price']); $new_service_no = mysql_real_escape_string($_POST['service']); if (empty($new_service_no) || $new_service_no = '0') { echo"<div class='alert alert-error'>You need to select an item</div>"; } else { $insert = mysql_query("INSERT INTO items (invoice_no, item_no, item_type, price) VALUES ('$get_invoice','$new_service_no','Service', '$item_price')"); header("Location:generate_invoice.php?car=$get_car_reg&invoice=$get_invoice"); } } } } ///$query="SELECT sum(price) FROM Fuel"; ?> <div class="left-column"> <form class="form" action="" method='POST'> <div class="control-group"> <label>Select Service</label> <div class="controls"> <select name="service"> <option value="0">Select one</option> <?php $select_services = mysql_query("SELECT * FROM services"); while ($row = mysql_fetch_array($select_services)) { $service_name = $row['service_name']; $service_price = $row['service_price']; $service_no = $row['service_no']; echo"<option value='$service_no'>$service_name</option>"; } ?> </select></div></div> <input type="hidden" name="item_price" value="<?php echo"$service_price"; ?>"> <button type="submit" name="add-service" class="btn btn-primary">Add</button> </form> <hr/> <form class="form" action="" method="post"> <div class="control-group"> <label>Select Products</label> <div class="controls"> <select name="product_no"> <option value="0">Select one</option> <?php $select_products = mysql_query("SELECT * FROM products"); while ($row = mysql_fetch_array($select_products)) { $product_sku = $row['sku']; $product_price = $row['price']; $product_name = $row['product_name']; echo"<option value='$product_sku'>$product_name</option>"; } ?> </select></div></div> <input type="hidden" name="item_price" value="<?php echo"$product_price"; ?>"> <button type="submit" name="add-product" class="btn btn-primary">Add</button> </form> <hr/> </div> <div class="right-column"> <table class="table"> <thead> <tr> <th>#</th> <th>Item Type</th> <th>Item Name</th> <th>Item No</th> <th>Price</th> <th>Remove</th> </tr> </thead> <tbody> <tr> <?php $select = mysql_query("SELECT * FROM items WHERE invoice_no='$get_invoice'"); while ($row = mysql_fetch_array($select)) { $current_item_id = $row['id']; $current_item_type = $row['item_type']; $current_item_no = $row['item_no']; $current_item_price = $row['price']; $select_item_name = mysql_query("SELECT * FROM services WHERE service_no='$current_item_no'"); if (mysql_num_rows($select_item_name) == 1) { while ($row = mysql_fetch_array($select_item_name)) { $current_item_name = $row['service_name']; } } /// else { $select_item_name = mysql_query("SELECT * FROM products WHERE sku='$current_item_no'"); if (mysql_num_rows($select_item_name) == 1) { while ($row = mysql_fetch_array($select_item_name)) { $current_item_name = $row['product_name']; } } /// } echo" <tr> <td>$current_item_id</td> <td>$current_item_type</td> <td>$current_item_name</td> <td>$current_item_no</td> <td>&pound$current_item_price</td> <td><form method='post' action=''><input type='hidden' name='delete_me' value='$current_item_id'><input type='submit' class='btn btn-danger' name='delete' value='Delete'></form></td> </tr> "; } ?> </tbody> </table> <form method="post" action=""> <table class="table"> <thead> <tr> <th>Discount</th> <th>Subtotal</th> <th>Total</th> </tr> </thead> <tbody> <tr> <td><input type="text" name='final_discount' placeholder='2.99' class='input input-mini'/></td> <td><?php $subtotal = mysql_query("SELECT sum(price) FROM items WHERE invoice_no='$get_invoice'"); $invoice_sub = mysql_fetch_array($subtotal); echo"&pound$invoice_sub[0]"; ?> </td> <td><?php $vat_q = mysql_query("SELECT * FROM company_config WHERE id='1'"); while ($row = mysql_fetch_array($vat_q)) { $vat = $row['vat_percentage']; } $total_vat = $vat * $invoice_sub[0] / 100; $total = $total_vat + $invoice_sub[0]; echo"&pound$total"; ?></td> </tr> </tbody> </table> <input type='hidden' name='final_total' value='<?php echo"$total"; ?>'> <input type='hidden' name='final_sub_total' value='<?php echo"$invoice_sub[0]"; ?>'> <input type='hidden' name='final_vat' value='<?php echo"floor($total_vat)"; ?>'> <div class='btn-group'> <button class='btn btn-primary' name='sp' type='submit'>Save & Print</button> </div> </form> </div> <?php include_once('includes/footer.php'); ?>
  6. I have this in my header, its really strange driving me crazy
  7. Yeah I have it in header, haven't included header here but yes I do.
  8. Hi guys, im trying to send this email with attachment but it doesn't give me any error and it doesn't send any emails. I have echoed out send to address and have had added echo on every step to see where issue is but it passes everything and doesn't send anything. Can you please help, driving me nuts for last two days, <?php if (isset($_POST['work'])){ $email=mysql_escape_string($_POST['email']); $phone=mysql_real_escape_string($_POST['phone']); $myaddress=mysql_real_escape_string($_POST['address_1']); $city=mysql_real_escape_string($_POST['city']); $zip=mysql_real_escape_string($_POST['zip']); $country=mysql_real_escape_string($_POST['country']); $covering=mysql_real_escape_string($_POST['covering']); $signature=mysql_real_escape_string($_POST['signature']); $upload_name=$_FILES["upload"]["name"]; $upload_type=$_FILES["upload"]["type"]; $upload_size=$_FILES["upload"]["size"]; $upload_temp=$_FILES["upload"]["tmp_name"]; $to='roozbeh.jalali@me.com'; $fp = fopen($upload_temp, "rb"); $file = fread($fp, $upload_size); $file = chunk_split(base64_encode($file)); $num = md5(time()); $subject = 'Work wit us'; $message =" <html> <head> <title>Jobs</title> </head> <body> <p>Name: $signature</p> <p>Email: $email</p> <p>Phone: $phone</p> <p>Address: $myaddress</p> <p>City: $city</p> <p>Zip: $zip</p> <p>Country: $country</p> <p>Covering Note: $covering</p> </body> </html> "; $headers = "From: Work With us<".$email.">\r\n"; $headers .= "MIME-Version: 1.0\r\n"; $headers .= "Content-Type: multipart/mixed; "; $headers .= "boundary=".$num."\r\n"; $headers .= "--$num\r\n"; $headers .= "Message-ID: <".gettimeofday()." TheSystem@".$_SERVER['SERVER_NAME'].">\r\n"; $headers .= "X-Mailer: PHP v".phpversion()."\r\n"; $headers .= "Content-Type: text/html; charset=iso-8859-1\r\n"; $headers .= "Content-Transfer-Encoding: 8bit\r\n"; $headers .= "".$message."\n"; $headers .= "--".$num."\n"; $headers .= "Content-Type:".$upload_type." "; $headers .= "name=\"".$upload_name."\"r\n"; $headers .= "Content-Transfer-Encoding: base64\r\n"; $headers .= "Content-Disposition: attachment; "; $headers .= "filename=\"".$upload_name."\"\r\n\n"; $headers .= "".$file."\r\n"; $headers .= "--".$num."--"; mail($to, $subject, $message, $headers); fclose($fp); } ?> <form action="<?php echo htmlentities($_SERVER['PHP_SELF']); ?>" class="ddd" method="post" id="work" enctype="multipart/form-data"> <h1 class='titles-400'>Work with us</h1><br/> <h2 class="subheader">Submit Your CV</h2> <div class="control-group"> <label class="control-label" for="inputEmail">Full Name:</label> <div class="controls"> <input type="text" class="validate[required] text-input" name="signature"/> </div> </div> <div class="control-group"> <label class="control-label" for="inputEmail">Email</label> <div class="controls"> <input type="email" name="email" class="validate[required,custom[email]] text-input"/> </div> </div> <div class="control-group"> <label class="control-label" for="inputEmail">Phone:</label> <div class="controls"> <input type="text" class="validate[required] text-input" name="phone"/> </div> </div> <div class="control-group"> <label class="control-label" for="inputEmail">Address:</label> <div class="controls"> <input type="text" name="address_1" class="validate[required] text-input" /> </div> </div> <div class="control-group"> <label class="control-label" for="inputEmail">City:</label> <div class="controls"> <input type="text" class="validate[required] text-input" name="city"/> </div> </div> <div class="control-group"> <label class="control-label" for="inputEmail">Zip / Postal Code:</label> <div class="controls"> <input type="text" class="validate[required] text-input" name="zip"/> </div> </div> <div class="control-group"> <label class="control-label" for="inputEmail">Country:</label> <div class="controls"> <input type="text" class="validate[required] text-input" name="country"/> </div> </div> <div class="control-group"> <label class="control-label" for="inputEmail">Covering Note:</label> <div class="controls"> <textarea class="validate[required] text-input span9" name="covering" rows="10"></textarea> </div> </div> <div class="control-group"> <label class="control-label" for="inputEmail">Upload CV</label> <div class="controls"> <input type="file" name="upload" id="file" class="validate[required]"> <span class="help-block">(Must be .doc, .docx, .pdf or .rtf and 1Mb or less)</span> </div> <label class="control-label" for="how">How did you hear about us?</label> <div class="controls"> <select name="how" class="validate[required]"> <option value="">- Please Select -</option> <option value="YouTube">YouTube</option> <option value="Facebook">Facebook</option> <option value="Twitter">Twitter</option> <option value="Friends">Friends</option> <option value="Search Engine">Search Engine</option> <option value="Email Campaign">Email Campaign</option> <option value="Other">Other</option> </select> </div> </div> <div class="control-group"> <div class="controls"> <button type="submit" class="btn btn-custom" name="work">Submit</button> </div> </div> </form> Thank you all in advance
  9. Hi guys, I am trying to send a html email via phpmail but keep receiving variables rather than data. $to = 'me@me.com'; // subject $subject = 'title'; // message $message =' <html> <head> </head> <body> <p>How you have been effected: $effected</p> <p>URL: $url</p> <p>Company: $company</p> <p>Position: $position</p> <p>Email: $email</p> <p>Alternative Email: $alt_email</p> <p>Phone: $phone</p> <p>Address: $address</p> <p>City: $city</p> <p>Zip: $zip</p> <p>Country: $country</p> <p>Website: $website</p> <p>Signature: $signature</p> </body> </html> '; $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; $headers .= 'From: Me <no-reply@me.com>' . "\r\n"; mail($to, $subject, $message, $headers); I have also keep changing ' to " this is what i keep getting no matter what How you have been effected: $effected URL: $url Company: $company Position: $position Email: $email Alternative Email: $alt_email Phone: $phone Address: $address City: $city Zip: $zip Country: $country Website: $website Signature: $signature Any ideas? Thanks all in advance
  10. sorry one more question, now if i want to present this as a url then what i need to do? doing below put them all in one link echo'<a href="../actors/index.php?name='.$actor_name.'">'.$actor_name.'</a>';
  11. You are an absolute hero dude, well done, worked like a charm
  12. Thanks but how? im almost new to php
  13. Did that and still get the same result $select_actors=mysql_query("SELECT * FROM actors_in_movies WHERE movie_ref='$movie_ref'"); if (mysql_num_rows($select_actors)>=1) { while ($row=mysql_fetch_array($select_actors)) { $actor_ref=$row['actor_ref']; $select_actor_name=mysql_query("SELECT * FROM actors WHERE actors_ref='$actor_ref' AND active='1'"); while ($row_actor=mysql_fetch_array($select_actor_name)) { $actor_name .= $row_actor['actors_name'] . ","; } $actor_name = substr(trim($actor_name), 0, -1); echo " $actor_name"; } }
  14. Hi guys, I have a very basic issue, Im trying to get these results (List all result with coma and delete last coma) like : actor 1, actor 2 My total entries are two in mysql but i get first result duplicated and no coma! This is my code, could you please help me spotting my mistake? Thank you all $select_actors=mysql_query("SELECT * FROM actors_in_movies WHERE movie_ref='$movie_ref'"); if (mysql_num_rows($select_actors)>=1) { while ($row=mysql_fetch_array($select_actors)) { $actor_ref=$row['actor_ref']; $select_actor_name=mysql_query("SELECT * FROM actors WHERE actors_ref='$actor_ref' AND active='1'"); while ($row_actor=mysql_fetch_array($select_actor_name)) { $actor_name.=$row_actor['actors_name'].","; $actor_name = substr(trim($actor_name), 0, -1); echo" $actor_name"; }}}
  15. hi guys, Im trying to calculate number of days and time passed a time stamp but I always get 0 do you know why? Am I making funny mistake again? date_bought= "2013-06-02 15:57:04"; $add_days = 7; $date= date('Y-m-d',strtotime( $date_bought) + (24*3600*$add_days)); $result_date= $date - $date_bought; echo"$result_date";
×
×
  • 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.