anshuverma1989 Posted August 30, 2009 Share Posted August 30, 2009 Hey, I have designed this shopping cart. Now what I want is when ever the person clicks on Ask For Quote, I should receive an email with the details mentioned in the cart. Please help me how can i go about it: Here is the coding: <?php // includes include('conf.php'); // Include functions require_once('inc/functions.inc.php'); // Include MySQL class require_once('inc/mysql.class.php'); // Include database connection require_once('inc/global.inc.php'); // Start the session session_start(); // generate and execute query $squery = "SELECT * FROM site_config WHERE id = 1"; $sresult = mysql_query($squery) or die ("Error in query: $squery. " . mysql_error()); // get resultset as object $srow = mysql_fetch_object($sresult); ?> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <title><?php echo $srow->site_title; ?></title> <meta name="keywords" content="<?php echo $srow->keywords; ?>" /> <meta name="description" content="<?php echo $srow->description; ?>" /> <link href="styles.css" rel="stylesheet" type="text/css" media="screen" /> </head> <body> <div id="content"> <!-- header begins --> <div id="header"> <div id="logo"> </div> <div id="menu"> <ul> <li><a href="index.php" title="">Home</a></li> <?php // query for menu $query = "SELECT * FROM pages"; $result = mysql_query($query) or die ("Error in query: $query. " . mysql_error()); // if records present if (mysql_num_rows($result) > 0) { // iterate through resultset // print article titles while($row = mysql_fetch_object($result)) { ?> <li><a href="page.php?id= <?php echo $row->id; ?>"><?php echo $row->menu_text; ?></a></li> <?php } } // if no records present // display message else { ?> <?php } ?> <li><a href="products.php" title="">Products</a></li> <li><a href="contact.php" title="">Contact</a></li> </ul> </div> </div> <!-- header ends --> <!-- main begins --> <div id="main"> <div id="main2"> <div id="left"> <h2>Details</h2><br /> <p><?php function showCart_final() { global $db; $cart = $_SESSION['cart']; if ($cart) { $items = explode(',',$cart); $contents = array(); foreach ($items as $item) { $contents[$item] = (isset($contents[$item])) ? $contents[$item] + 1 : 1; } $output[] = '<form action="cart.php?action=update" method="post" id="cart">'; $output[] = '<table width=100%>'; $output[] = '<tr><td><font face="Verdana" size="2"><strong>Image</strong></font></td><td><font face="Verdana" size="2"><strong>Product I.D</strong></font></td><td><font face="Verdana" size="2"><strong>Quantity</strong></font></td>'; foreach ($contents as $id=>$qty) { $sql = 'SELECT * FROM products WHERE id = '.$id; $result = $db->query($sql); $row = $result->fetch(); extract($row); $output[] = '<tr>'; $output[] = '<td><img src="uploaded/'.$picture.'" width=100 height = 100></td>'; $output[] = '<td><font face="Verdana" size="2">'.$pro_id.'</font></td>'; $output[] = '<td ><font face="Verdana" size="2">'.$qty.'</font></td>'; $output[] = '</tr>'; } $output[] = '</table>'; $output[] = '<br />Name: <input type="text" name="name"><br /><br />'; $output[] = 'Email: <input type="text" name="email"><br /><br />'; $output[] = 'Contact Number: <input type="text" name="number"><br /><br />'; $output[] = '<div><button type="submit" value="ask">Ask For Quote</button></div>'; $output[] = '</form>'; } else { $output[] = '<p>You shopping cart is empty.</p>'; } return join('',$output); } echo showCart_final(); ?> </p> </div> <div id="right"> <div class="titl_right">categories</div> <div class="ug"> <ul> <?php // query for menu $cquery = "SELECT * FROM category"; $cresult = mysql_query($cquery) or die ("Error in query: $cquery. " . mysql_error()); // if records present if (mysql_num_rows($cresult) > 0) { // iterate through resultset // print article titles while($crow = mysql_fetch_object($cresult)) { ?> <li><a href="category.php?id= <?php echo $crow->id; ?>"><?php echo $crow->category; ?></a></li> <?php } } // if no records present // display message else { ?> <?php } ?> </ul> </div> <div class="titl_right">quotation cart</div> <div id="calendar"> <div id="calendar1"> <?php echo writeShoppingCart(); ?> </div> </div> <br /> </div> <div style="clear: both"></div> </div> </div> <div id="bottom"></div> </div> <div id="footer"> </div> </body> </html> Can someone please help me with this.. Link to comment https://forums.phpfreaks.com/topic/172444-contact-form/ Share on other sites More sharing options...
redarrow Posted August 30, 2009 Share Posted August 30, 2009 use session's when the button is pressed and use the php mail function. look at my sig for a mail example. Link to comment https://forums.phpfreaks.com/topic/172444-contact-form/#findComment-909165 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.