{Solved}:hi, i need some help in chech out code :\
Posted: Wed Apr 18, 2012 7:21 am
hi guys
i have this cart.php code:
and this is my contact form:
.
now, i need when i click check out to get all products and send him to email :\
any suggestions ?
thank you
i have this cart.php code:
Code: Select all
<?php
if(cart_empty()){
echo 'Cart is empty.';
}else {
if(isset($_POST['id'], $_POST['quantity']))
{
update_quantity($_POST['id'], $_POST['quantity']);
}
foreach($_SESSION['cart'] as $product => $quantity)
{
$info = get_details($product);
if($info !== null){
?>
<div style="border:1px dashed #c9c9c9; width:400px;">
<h3><?php echo $info['pages_header']; ?></h3>
<h4 style="color:red;">Price for 1 product: <span style="color:#e27c0e;"><?php echo $info['pages_price']; ?></span></h4>
<center><img src="<?php echo $info['pages_pic']; ?>" width="93" height="101" border="0" alt=""></center>
<p><?php echo $info['pages_text']; ?></p>
<div>
<form action="cart.php" method="post">
<label for="quantity">Quantity: </label><input name="quantity" type="text" value="<?php echo $quantity; ?>" size="2" maxlength="2" />
<input type="hidden" name="id" value="<?php echo $product; ?>" />
<input type="submit" value="Update quantity" />
</form>
<a style="color:red; text-decoration:none;" href="remove_from_cart.php?id=<?php echo $product; ?>">Remove from cart</a>
</div>
</div></br></br>
<?php
}
}
}
?>
Code: Select all
<?php
ob_start();
//Contact us error array
$err=array();
//If the user presses "send" button,this code is executed
if(($_SERVER['REQUEST_METHOD']=="POST") && (isset($_POST['contact'])))
{
//Removing forbidden symbols to prevent SQL Injection,XSS attacks and removing spaces
foreach($_POST as $key=>$value)
{
$_POST[$key]=addslashes(strip_tags(trim($value)));
}
//Extracting array into variables
extract($_POST);
//Checking the name of the sender
if(!empty($name))
{
if(preg_match("/^[a-zא-תا-ي ]+$/i",$name))
{
if((strlen($name)<2) || (strlen($name)>50))
{
$err[]="Your name has to be between 2 and 50 symbols";
}
}
else
{
$err[]="Your name can contain letters only";
}
}
else
{
$err[]="Please enter your name";
}
//Checking the phone number
if(!empty($phone))
{
if(is_numeric($phone))
{
if((strlen($phone)<7) || (strlen($phone)>18))
{
$err[]="Your phone number has to be between 7 and 18 symbols";
}
}
else
{
$err[]="Your phone number can contain digits only";
}
}
else
{
$err[]="Please enter your phone number";
}
//Checking the email of the sender
if(!empty($email))
{
if(!filter_var($email,FILTER_VALIDATE_EMAIL))
{
$err[]="Wrong email input format";
}
}
else
{
$err[]="Please enter your email";
}
//Checking the user's message
if(empty($message))
{
$err[]="Please enter your message";
}
//If all the information entered by the user is correct,we send the message to the administrator
if(empty($err))
{
$message = "<div style='font-size:24px; font-weight:bold;color:green'>New Contact Message</div><div style='height:4px;background:gray'></div><div style='margin:2px 0 10px 0;height:1px;background:gray'></div><div>Hello Mikha,<br><br>There is a new contact message waiting for you:<br>Sender:<b>".$name."</b><br>Email:<b>".$email."</b><br>Phone number:".$phone."<br><br>Message:<b>".$message."</b><br>Site Team</div><div style='margin:5px 0;height:4px;background:gray'></div>";
$headers = 'MIME-Version: 1.0' . "\r\n" . 'Content-type: text/html; charset=UTF-8' . "\r\n";
$headers .= 'To: Mikha Matta <mekha.r99@gmail.com>' . "\r\n";
$headers .= 'From: <info@mysite.com>' . "\r\n";
mail("mekha.r99@gmail.com", 'A new contact message is received'.time(), $message, $headers);
?>
<script type="text/javascript">location.href="contact_form.php?th=1"</script>
<?php
die();
}
}
if((isset($_GET['th'])) && ($_GET['th']==1))
{
?>
<script type="text/javascript">alert('Thank you your message was sent!');location.href="index.php"</script>
<?php
}
else
{
?>
<form method="post">
<table border="0" align="center" width="300px">
<tr>
<td><p>Name:</p></td>
<td><input type="text" class="forms" maxlength="50" name="name" /></td>
</tr>
<tr>
<td><p>Phone Number:</p></td>
<td><input type="text" class="forms" maxlength="50" name="phone" /></td>
</tr>
<tr>
<td><p>Email:</p></td>
<td><input type="text" class="forms" maxlength="80" name="email" /></td>
</tr>
<tr>
<td><p>Your message:</p></td>
<td><textarea class="forms" name="message" rows="10" cols="25" wrap="physical"></textarea></td>
</tr>
<tr>
<td> </td>
<td style="padding-left:22px;"><input type="submit" style="cursor:pointer;" value="Send" name="contact" /></td>
</tr>
<?php
//If the information entered by the user isn't correct,we display the errors here:
if(!empty($err))
{
?>
<tr>
<th colspan="2">
<?php
foreach($err as $value)
{
echo '<span class="errors">'.$value.'</span><br />';
}
?>
</th>
</tr>
<?php
}
?>
</table>
</form>
<?php
}
?>
now, i need when i click check out to get all products and send him to email :\
any suggestions ?
thank you