PHP - Php Email Script / How Do I 'include()
Trying to use an include() in a script to send an email, not working out. Basically I have a pretty drastic page I've formatted out and I want it to be shipped out in an email in that format. I thought it would be simple to get an include in a php code to email but the email works.. and doesn't have anything in it.
I've tried with and without quotes, any help appreciated. Code: [Select] <html> <body> <? //change this to your email. $to = "me@me.com"; $from = "me@me.com"; $subject = "stuff"; $message="<?php include("another.php"); ?>" $headers = "From: $from\r\n"; $headers .= "Content-type: text/html\r\n"; //options to send to cc+bcc //$headers .= "Cc: [email]maa@p-i-s.cXom[/email]"; //$headers .= "Bcc: [email]email@maaking.cXom[/email]"; // now lets send the email. mail($to, $subject, $message, $headers); echo "Message has been sent....!"; ?> </html> </body> Similar TutorialsHi there, I have created a simple php email form, which works just fine, but now I have been asked to include an image of the company logoat the top of the email the user receives. I am new to php, so my first thought was that I could just add a line that had the path to the image on the server like so: $mailimg = 'http://domain.ca/images/image.gif'; and then call it in the $message: $headers = "From: $email\r\n\r\n"; $subject = "Cancellation Request Form from Website"; $message .= "$mailimg"; $message = "Notice Date: $ndate\r Brokerage: $brokerage\r but that doesnt seem to be working for me. I get the email message, but with no image attached. Any ideas on how I can simply do this. Again I am new to php, so the easier the better Here is my code Code: [Select] <?php if ($_SERVER['REQUEST_METHOD'] != 'POST'){ $me = $_SERVER['PHP_SELF']; ?> <form name="form1" method="post" action="<?php echo $me;?>"> <table width="97%" border="0" align="center" cellpadding="0" cellspacing="0"> <tr> <td><img src="../images/dot_trans.gif" width="2" height="2" /><br /> <table width="97%" border="0" align="center" cellpadding="0" cellspacing="0"> <tr> <td><img src="../images/dot_trans.gif" width="10" height="10" /><br /> <table width="100%" height="183" border="0" align="center" cellpadding="3" cellspacing="3"> <tr> <td width="147"><strong>Notice Date</strong></td> <td width="263"><span id="sprytextfield1"> <label> <input name="ndate" type="text" id="ndate" size="40" /> </label> <span class="textfieldRequiredMsg">Please Enter Notice Date.</span></span></td> <td width="127"><strong>Broker Name</strong></td> <td width="271"><span id="sprytextfield7"> <input name="brokername" type="text" id="brokername" size="40" /> <span class="textfieldRequiredMsg">Please Enter Broker Name.</span></span></td> </tr> <tr> <td><strong>Brokerage</strong></td> <td><span id="sprytextfield2"> <label> <input name="brokerage" type="text" id="brokerage" size="40" /> </label> <span class="textfieldRequiredMsg">Please Enter Brokerage</span></span></td> <td><strong>Phone Number</strong></td> <td><span id="sprytextfield8"> <input name="pnum" type="text" id="pnum" size="40" /> <span class="textfieldRequiredMsg">Please Enter A Phone Number.</span></span></td> </tr> <tr> <td><strong>RJFC Contract #</strong></td> <td><span id="sprytextfield3"> <input name="rjfccon" type="text" id="rjfccon" size="40" /> <span class="textfieldRequiredMsg">Please Enter A Contact Number</span></span></td> <td><strong>E Mail</strong></td> <td><span id="sprytextfield9"> <input name="email" type="text" id="email" size="40" /> <span class="textfieldRequiredMsg">Please Enter A E Mail Address.</span><span class="textfieldInvalidFormatMsg">Invalid format.</span></span></td> </tr> <tr> <td height="28"><strong>Insured</strong></td> <td><span id="sprytextfield4"> <input name="insured" type="text" id="insured" size="40" /> <span class="textfieldRequiredMsg">Please Enter Name of Insured</span></span></td> <td rowspan="3" valign="top"><strong>Reason for cancellation</strong></td> <td rowspan="3"><label for="cancel"></label> <span id="sprytextarea1"> <textarea name="cancel" id="cancel" cols="30" rows="5"></textarea> <span class="textareaRequiredMsg">Please enter a reason for cancellation.</span></span></td> </tr> <tr> <td height="28"><strong>Policy #</strong></td> <td><span id="sprytextfield5"> <input name="polnum" type="text" id="polnum" size="40" /> <span class="textfieldRequiredMsg">Please Enter A Policy Number.</span></span></td> </tr> <tr> <td height="22"> </td> <td> </td> </tr> </table> <br /> <br /> <table width="822" align="center" cellpadding="0" cellspacing="0"> <tr> <td width="569"><div align="left">RJFC will process the Cancellation Request upon receipt. All documents will be sent to the Insured by registered mail. A fax or e-mail copy of the documents will be sent to the Broker and Insurer. </div> <p> </p></td> </tr> </table> <table width="97%" border="0" align="center" cellpadding="3" cellspacing="3"> <tr> <td width="801"><div align="center"> <label> <input name="Submit" type="submit" value="Submit" /> </label> <label> <input name="reset" type="reset" id="reset" value="Reset" /> </label> </div></td> </tr> </table> <img src="../images/dot_trans.gif" width="10" height="10" /></td> </tr> </table> <img src="../images/dot_trans.gif" width="2" height="2" /></td> </tr> </table> </form> <?php } else { error_reporting(0); $recipient = 'contact@justspiffy.ca'; $ndate = stripslashes($_POST['ndate']); $brokerage = stripslashes($_POST['brokerage']); $rjfccon = stripslashes($_POST['rjfccon']); $insured = stripslashes($_POST['insured']); $polnum = stripslashes($_POST['polnum']); $brokername = stripslashes($_POST['brokername']); $pnum = stripslashes($_POST['pnum']); $email = stripslashes($_POST['email']); $cancel = stripslashes($_POST['cancel']); $mailimg = 'http://rjfc.ca/new/images/quote.gif'; putenv ("QMAILUSER=contact"); putenv ("QMAILNAME=contact@justspiffy.ca"); putenv ("QMAILHOST=justspiffy.ca"); $headers = "MIME-Version: 1.0\r\n"; $headers .= "Content-type: multipart/mixed;charset=us-ascii\r\n"; $headers .= "From: contact@justspiffy.ca"; $headers = "From: $email\r\n\r\n"; $subject = "Cancellation Request Form from Website"; $message .= "$mailimg"; $message = "Notice Date: $ndate\r Brokerage: $brokerage\r RJFC Contact Number: $rjfccon\r Insured: $insured\r Policy Number: $polnum\r Broker Name: $brokername\r Phone Number: $pnum\r Email: $email\r Reason for cancellation: $cancel\r "; mail($recipient, $subject, $message, $headers); if (!mail) { echo "Message failed to send"; } else { echo nl2br ("<center><br><br><br><br><br><br><br><br><br><br>Thank you. Your request has been sent. A representative from RJFC will contact you shortly.<br><br><br><br><br><br><br><br><br><br></center>"); } } ?> I'm trying to use this script known as SimpleImage.php that can be found here <a href="http://www.white-hat-web-design.co.uk/articles/php-image-resizing.php">link</a> I'm trying to include what is on the bottom of the page to my existing script can anyone help me I've tried several ways but its not working. Code: [Select] <?php session_start(); error_reporting(E_ALL); ini_set('display_errors','On'); //error_reporting(E_ALL); // image upload folder $image_folder = 'images/classified/'; // fieldnames in form $all_file_fields = array('image1', 'image2' ,'image3', 'image4'); // allowed filetypes $file_types = array('jpg','gif','png'); // max filesize 5mb $max_size = 5000000; //echo'<pre>';print_r($_FILES);exit; $time = time(); $count = 1; foreach($all_file_fields as $fieldname){ if($_FILES[$fieldname]['name'] != ''){ $type = substr($_FILES[$fieldname]['name'], -3, 3); // check filetype if(in_array(strtolower($type), $file_types)){ //check filesize if($_FILES[$fieldname]['size']>$max_size){ $error = "File too big. Max filesize is ".$max_size." MB"; }else{ // new filename $filename = str_replace(' ','',$myusername).'_'.$time.'_'.$count.'.'.$type; // move/upload file $target_path = $image_folder.basename($filename); move_uploaded_file($_FILES[$fieldname]['tmp_name'], $target_path); //save array with filenames $images[$count] = $image_folder.$filename; $count = $count+1; }//end if }else{ $error = "Please use jpg, gif, png files"; }//end if }//end if }//end foreach if($error != ''){ echo $error; }else{ /* -------------------------------------------------------------------------------------------------- SAVE TO DATABASE ------------------------------------------------------------------------------------ -------------------------------------------------------------------------------------------------- */ ?> Hi all, I am just starting out in the world of php and have got this far with a lot of googling. But I'm really stuck with this part now. I have a function that works perfectly for display on a page, eg <?php echo quickquote(); ?> function quickquote() { global $db; global $cart; $cart = $_SESSION['cart']; if ($cart) { $items = explode(',',$cart); $contents = array(); foreach ($items as $item) { $contents[$item] = (isset($contents[$item])) ? $contents[$item] + 1 : 1; } $quickquote[] = 'Quote Required:<br />'; foreach ($contents as $id=>$qty) { $sql = 'SELECT * FROM products WHERE id = '.$id; $result = $db->query($sql); $row = $result->fetch(); extract($row); $quickquote[] = ''.$qty.''; $quickquote[] = ' x '; $quickquote[] = '' . $model . ''; $quickquote[] = ' (' . $type . '- '; $quickquote[] = ''. $basin . '- '; $quickquote[] = ''. $top . ')'; $quickquote[] = '<br />'; } $quickquote[] = 'End of Quick Quote Request'; } else { $quickquote[] = 'The quote cart is empty.'; } return join('',$quickquote); } However, i am trying to include this in an email message: if(!$error) { $messages="From: $email <br>"; $messages.="Name: $name <br>"; $messages.="Email: $email <br>"; $messages.="Phone: $phone <br>"; $messages.="Message: $message <br>"; $messages.="Quick Quote Request: $quickquote <br>"; $mail = mail($to,$subject,$messages,$headers); The email also works perfectly with the exception that the data is not there from $quickquote. I've tried all sorts of variations and suggested solutions from the web but nothing I've tried has been successful so far. It's amazing that I've got this far so I don't want to give up on it, but I'm just completely stumped ... All information and help very much appreciated. Cheers K Hi, n0obie here. I'm trying to identify where my customers are coming from via emails I've sent/received. However, many email providers (namely Gmail) have circumvented this by disallowing IP address geolocation/image caching. Code: [Select] $sql="SELECT * FROM $tbl_name3 WHERE review_show='n'"; $result=mysql_query($sql); $num_results=mysql_num_rows($result); if($num_results > 1){ $message="You have ".$num_results." reviews unapproved."; mail('example@example.com','GHP Reviews', $message, 'From: example@example.com'); } $sql2="SELECT * FROM $tbl_name4 WHERE rma_issued='n'"; $result2=mysql_query($sql2); $num_results2=mysql_num_rows($result2); if($num_results2 > 1){ $message="You have ".$num_results2." RMA Numbers Requested."; mail('example@example.com','GHP RMA Number Requests', $message, 'From: example@example.com'); } The reviews email is being sent, however, the RMA email is not. EDIT: Nevermind, $num_results and $num_results2 should have been > 0 not > 1. Hi Everyone! Thanks in advance for taking the time to review my post. I am pretty new to PHP so please excuse my ignorance. I am working a project for myself. I want to be able to send out newsletters to my customers and sponsors. I have written the code and here it is: <?php $subject = $_POST['subject']; $message = $_POST['message']; $email = "bubba@bubba.com"; $headers = "From: $email"; $email_list = file("elist.txt"); $total_emails = count($email_list); for ($counter=0; $counter<$total_emails; $counter++) { $email_list[$counter] = trim($email_list[$counter]); } $to = implode(",",$email_list); if ( mail($to,$subject,$message,$headers) ) { echo "The email has been sent!"; } else { echo "The email has failed!"; } ?> ----------------------------------------------------------------------------- In my elist.txt file - I have two fields. Name and email. Bubba|bubba@bubba.com Oohay|oohay@yahoo.com If i leave the names out of this file, the email script works great! I want to leave the names in there and reference them in my email that I am sending out to be more personal. Can this be done and can you help? Thanks! Mike The PHP code sends me an email from the server, but the user input is empty or "blank". I only receive: "From: \ Email: \ Subject: \ Message: " and that's it. How do I fix my PHP and/or HTML code to receive user input from the form? Attached is my existing HTML and PHP code that doesn't send me any "user input" from the form. Thanks to anyone who can help!!
Hi I have previously posted this in the Jquery section but im not so sure its a Jquery issue now, so apoligies for the double post. I am having an issue with a rating system that works if i access the gamecards.php file through its absolute path (www..../...../gamecards.php) but will not work if i access it through a file that it is an include of (www..../reviews.php) Basicaly, when i click on the link through the include, the data is not sent to the DB and the data does not refresh. gamecards.php all works fine when its not as an include. Any ideas why? Gamecards.php is posted below Code: [Select] <!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=iso-8859-1" /> <script type="text/javascript" src="jquery.js"></script> <script type="text/javascript"> $(function() { $(".vote").click(function() { var id = $(this).attr("id"); var name = $(this).attr("name"); var dataString = 'id='+ id ; var parent = $(this); if(name=='up') { $(this).fadeIn(200).html('<img src="dot.gif" align="absmiddle">'); $.ajax({ type: "POST", url: "up_vote.php", data: dataString, cache: false, success: function(html) { parent.html(html); } }); } else { $(this).fadeIn(200).html('<img src="dot.gif" align="absmiddle">'); $.ajax({ type: "POST", url: "down_vote.php", data: dataString, cache: false, success: function(html) { parent.html(html); } }); } return false; }); }); </script> </head> <body> <?php include('config.php'); //get results from db if (isset($_GET['gameid']) && is_numeric($_GET['gameid'])) { $gameid = mysql_real_escape_string($_GET['gameid']); $sql = "SELECT * FROM Games WHERE gameid = $gameid"; $res = mysql_query($sql); $data = mysql_fetch_assoc($res); // However you'd like to format the html to output $title=$data['gametitle']; $cover=$data['cover']; $gameid=$data['gameid']; $info=$data['info']; $genre=$data['genre']; $rdate=$data['releasedate']; $format=$data['format']; $dir1="coverart"; $reviews="Enter Reviews Here"; date("d/m/y",$rdate); echo "<div id='cardcontainer_full'> <div id='coverart'><img src='$dir1/{$cover}' width='100' height='140'><br></div> <div id='gametitle'>$title</div> <div id='features'>Gen $genre<br><br> Release Date: $rdate<br><br> Available for: $format<br><br> </div> <div id='gameinfo'><div style='font-weight:bold'>Summary</div><br>$info <p><div style='font-weight:bold'>Reviews</div><p>$reviews </div> </div>"; } else { $data = ''; if(isset($_GET['filter']) && $_GET['filter'] != ''){ $filter = $_GET['filter']."%"; }else{ // set A as default $filter = "a%"; } $sql = "SELECT * FROM Games WHERE gametitle LIKE '$filter' ORDER BY gametitle"; $res = mysql_query($sql) or die(mysql_error()); if(mysql_num_rows($res) == 0) die("No records found"); // loop through the results returned by your query while($row = mysql_fetch_assoc($res)) { $title=$row['gametitle']; $cover=$row['cover']; $gameid=$row['gameid']; $up=$row['up']; $down=$row['down']; // directory for images $dir="coverart"; ?> <div id="cardcontainer"> <div id="coverart"> <?php echo "<img src='$dir/{$cover}' width='100' height='140'><br>"; ?> </div> <div id="gametitle"> <a href="Reviews.php?gameid=<?php echo $gameid ?>"><?php echo $title ?></a> </div> <div id="friendrating">Rate It<br /><a href="" class="vote" id="<?php echo $gameid; ?>" name="up"><?php echo $up; ?></a></div> <div id="globalrating">Hate It<br /><a href="" class="vote" id="<?php echo $gameid; ?>" name="down"><?php echo $down; ?></a></div> </div> <br /> <?php } } ?> </body> </html> Magento 1.9 - How to include custom PHP Script into .PHTML file My magento tracking page: https://i.stack.imgur.com/3GIoN.png Back-end magento code : https://i.stack.imgur.com/ySgMA.png How can i add my PHP script into this tracking page. Tracking page code - trackorder.phtml [ https://i.stack.imgur.com/ySgMA.png ]
<?php if(Mage::getStoreConfig('trackorder/trackorder_general/enabled')): ?> <div class="page-title"><h1><?php echo $this->__('Track Your Order ') ?></h1></div> <div class="form-list"> <form name="track_order" id="track_order" action="" method="post" onsubmit="sendAjax('track_order','<?php echo Mage::getUrl('*/*/track');?>'); return false;"> <!--<form name="track_order" method="post" id="track_order" action="<?php echo Mage::getUrl('*/*/view');?>">--> <ul class="form-list"> <li> <label for="order_id" class="required"><em>*</em><?php echo $this->__('Order Id') ?></label> <div class="input-box"> <input type="text" name="order_id" id="order_id" value="" title="" class="input-text required-entry" /> </div> </li> <li> <label for="email_address" class="required"><em>*</em><?php echo $this->__('Email Address') ?></label> <div class="input-box" > <input type="text" name="email" id="email_address" value="" title="<?php echo $this->__('Email Address') ?>" class="input-text validate-email required-entry" /> </div> </li> </ul> <div class="buttons-set"> <button type="submit" class="button" title="<?php echo $this->__('Track Order') ?>" name="track" id="track"> <span><span><?php echo $this->__('Track Order') ?></span></span> </button> </div> </form> <div id="loading-details" class="loading-details" style="display:none"> <div id="loading-mask" > <p class="loader" id="loading_mask_loader"><img src="<?php echo $this->getSkinUrl('trackorder/images/ajax-loader-tr.gif') ?>" alt="<?php echo Mage::helper('adminhtml')->__('Loading...') ?>"/><br/><?php echo $this->__('Please wait...') ?></p> </div> </div> </div> <div id="oderinfo" class="order-info-message"></div> <script type="text/javascript"> var validateForm = new VarienForm('track_order', true); </script> <script type="text/javascript"> function sendAjax(frmId,url){ if (!validateForm.validator.validate()) { return; } var data = $(frmId).serialize(this); $("loading-details").show(); new Ajax.Updater( { success:"oderinfo" }, url, { asynchronous:true, evalScripts:false, onComplete:function(request, json){ $("loading-details").hide(); return false; }, onLoading:function(request, json){}, parameters:data } ); return false; } </script> <?php else: ?> <?php $url = Mage::getBaseUrl(); Mage::app()->getFrontController()->getResponse()->setRedirect($url); ?> <?php endif; ?>
From above code how can i add my own PHP script : My PHP script :
<!DOCTYPE HTML> <html> <body> <form action="#" method="POST"> Select Courier : <select name="courier"> <option disabled='disabled' selected>-- Choose an option --</option> <option value="professional_courier">Professional Courier</option> <option value="shree_maruti_courier">Shree Maruti Courier</option> <option value="india_post_courier">India Post Courier</option> <option value="dhl_courier">DHL Courier</option> <option value="fedex_courier">Fedex Courier</option> <option value="ups_courier">UPS Courier</option> </select> Trackingid: <input type="text" name="trackingid"> <input type="submit"> </form> <?php if (isset($_POST['courier'])) { // Professional Courier if ('professional_courier' === $_POST['courier']) { header("Location: https://www.tpcindia.com/Tracking2014.aspx?id=" . $_POST["trackingid"] . "&type=0&service=0"); } // Shree Maruti Courier else if ('shree_maruti_courier' === $_POST['courier']) { header("Location: https://www.shreemaruticourier.com/track-your-shipment/#track-your", "_blank"); } // india_post_courier else if ('india_post_courier' === $_POST['courier']) { header("Location: https://www.indiapost.gov.in/vas/Pages/IndiaPostHome.aspx/#main-content", "_blank"); } // DHL Courier else if ('dhl_courier' === $_POST['courier']) { header("Location: https://www.dhl.com/en/express/tracking.html?AWB=" . $_POST["trackingid"] . "&brand=DHL", "_blank"); } // Fedex Courier else if ('fedex_courier' === $_POST['courier']) { header("Location: https://www.fedex.com/apps/fedextrack/?action=track&trackingnumber=" . $_POST["trackingid"] . "&cntry_code=in&locale=en_IN", "_blank"); } // ups_courier else if ('ups_courier' === $_POST['courier']) { header("Location: https://www.ups.com/track?loc=en_US&tracknum=" . $_POST["trackingid"] . "&requester=WT/trackdetails", "_blank"); } } ?> </body> </html>
My Workout in trackorder.phtml getting error : [start & end header added]
<?php if(Mage::getStoreConfig('trackorder/trackorder_general/enabled')): ?> <div class="page-title"><h1><?php echo $this->__('Track Your Order ') ?></h1></div> <div class="form-list" style="float: left;"> <form name="track_order" id="track_order" action="" method="post" onsubmit="sendAjax('track_order','<?php echo Mage::getUrl('*/*/track');?>'); return false;"> <!--<form name="track_order" method="post" id="track_order" action="<?php echo Mage::getUrl('*/*/view');?>">--> <ul class="form-list"> <li> <label for="order_id" class="required"><em>*</em><?php echo $this->__('Order Id') ?></label> <div class="input-box"> <input type="text" name="order_id" id="order_id" value="" title="" class="input-text required-entry" /> </div> </li> <li> <label for="email_address" class="required"><em>*</em><?php echo $this->__('Email Address') ?></label> <div class="input-box" > <input type="text" name="email" id="email_address" value="" title="<?php echo $this->__('Email Address') ?>" class="input-text validate-email required-entry" /> </div> </li> </ul> <div class="buttons-set"> <button type="submit" class="button" title="<?php echo $this->__('Track Order') ?>" name="track" id="track"> <span><span><?php echo $this->__('Track Order') ?></span></span> </button> </div> </form> <div id="loading-details" class="loading-details" style="display:none"> <div id="loading-mask" > <p class="loader" id="loading_mask_loader"><img src="<?php echo $this->getSkinUrl('trackorder/images/ajax-loader-tr.gif') ?>" alt="<?php echo Mage::helper('adminhtml')->__('Loading...') ?>"/><br/><?php echo $this->__('Please wait...') ?></p> </div> </div> </div> <!-- Start couier tracking --> <div style="float: left;"> <form action="#" method="POST" style="padding: 28px 15px 21px 196px;"> Select Courier : <select name="courier"> <option disabled='disabled' selected>-- Choose an option --</option> <option value="professional_courier">Professional Courier</option> <option value="shree_maruti_courier">Shree Maruti Courier</option> <option value="india_post_courier">India Post Courier</option> <option value="dhl_courier">DHL Courier</option> <option value="fedex_courier">Fedex Courier</option> <option value="ups_courier">UPS Courier</option> </select> Trackingid: <input type="text" name="trackingid"> <input type="submit"> </form> <?php if (isset($_POST['courier'])) { // Professional Courier if ('professional_courier' === $_POST['courier']) { header("Location: https://www.tpcindia.com/Tracking2014.aspx?id=" . $_POST["trackingid"] . "&type=0&service=0"); } // Shree Maruti Courier else if ('shree_maruti_courier' === $_POST['courier']) { header("Location: https://www.shreemaruticourier.com/track-your-shipment/#track-your", "_blank"); } // india_post_courier else if ('india_post_courier' === $_POST['courier']) { header("Location: https://www.indiapost.gov.in/vas/Pages/IndiaPostHome.aspx/#main-content", "_blank"); } // DHL Courier else if ('dhl_courier' === $_POST['courier']) { header("Location: https://www.dhl.com/en/express/tracking.html?AWB=" . $_POST["trackingid"] . "&brand=DHL", "_blank"); } // Fedex Courier else if ('fedex_courier' === $_POST['courier']) { header("Location: https://www.fedex.com/apps/fedextrack/?action=track&trackingnumber=" . $_POST["trackingid"] . "&cntry_code=in&locale=en_IN", "_blank"); } // ups_courier else if ('ups_courier' === $_POST['courier']) { header("Location: https://www.ups.com/track?loc=en_US&tracknum=" . $_POST["trackingid"] . "&requester=WT/trackdetails", "_blank"); } } ?> </div> <!-- End couier tracking --> <div id="oderinfo" class="order-info-message"></div> <script type="text/javascript"> var validateForm = new VarienForm('track_order', true); </script> <script type="text/javascript"> function sendAjax(frmId,url){ if (!validateForm.validator.validate()) { return; } var data = $(frmId).serialize(this); $("loading-details").show(); new Ajax.Updater( { success:"oderinfo" }, url, { asynchronous:true, evalScripts:false, onComplete:function(request, json){ $("loading-details").hide(); return false; }, onLoading:function(request, json){}, parameters:data } ); return false; } </script> <?php else: ?> <?php $url = Mage::getBaseUrl(); Mage::app()->getFrontController()->getResponse()->setRedirect($url); ?> <?php endif; ?>
Alright, so here's the problem. I am trying to code up a PHP script that basically sends an email. Sounds basic, right? Here's the tricky part. Using HTML or any other code will simply just load your default mail client and try to send it with that, what I need is a script that sends it via my website. I'll try to explain, Name: (This will send me their name they type) Email: (Same as above) Submit: (This will be the button they press when they submit the fore-mentioned details.) What would need to happen is the PHP would need to include the data entered in the name, and email field, (after the user clicks the submit button) copy it, and paste it into a email that is sent to my email address. (My email needs to be hidden obviously) But this needs to be done server side, without opening the person's mail client. And then once the email is sent, they need to be re-directed to a page. Only problem is, I CANNOT code PHP to save my life, I know this script is possible I've had it done before but lost the script Much appreciated anyone who can help me out on this one! I am experiencing compleate brain failure here please help if you can. This is my email script, how do i include multiple input, into the $body tag? example: vieweremail + comments + phonenumber + alot other stuff?? As of now i can only make it include 1 user input field thats is 'vieweremail'. <?php $to = $_POST['email_addy']; $subject = " your dating app"; $body = $_POST['vieweremail']; if (mail($to, $subject, $body)) { echo("<p>Message successfully sent!</p>"); } else { echo("<p>Message delivery failed...</p>"); } ?> Hi Guys I'm just looking for some advice to make sure i go in the right direction from the off! Building a new system for a client. They'll receive contact information from a contact form on their website and the details of the contact form are logged in the admin area of the cms. The client wants to be able to respond to these contacts via email without logging into the system and then have the details of the reply logged in the admin area of the cms to know when something has been responded to. So essentially i need some way of getting that email into the database. The only way i can see this happening is to setup a new mailbox, the client blind copies that mailbox address into all replies, a cron then runs a php script that picks up most recent emails via imap and then reads in the data - thereby registering the fact a response has happened (probably from the subject line reference) and it would then update the status of the contact. I am assuming this is theoretically possible as i've never done anything like that before. So... 1) Is there a better way of doing this without having the client login to the site to respond? 2) Does the proposal above sound reasonable? Any advice would be much appreciated... Drongo Guys Im having a strange issue with my code I have a form to request a password to be sent to email incase forgotten The script seems to run as it should as in taking the info then redirecting to the messages page for confirmation no problem but its not sending the email Ive checked and double checked, and even re written the code from scratch and nothing seems to be playing ball in sending the email Can someone shed some none sleep deprived eyes over it and point out what will no doubt be an obvious error I just cant seem to see The Form: Code: [Select] <form name="sendpw" method="post" action="sendpw.php"> <br> <table width="100%" border="0" class="tbl"> <tr> <td width="198"><div align="right">Username:</div></td> <td width="418"><input name="name" type="text" class="input" size="30"></td> </tr> <tr> <td><div align="right">Email: </div> </td> <td><input name="mail" type="text" class="input" size="30"></td> </tr> <tr> <td colspan="2"> <div align="center"> <input name="Submit" type="submit"> </div></td> </tr> </table> </form> The Script: Code: [Select] <? include ('config.php'); $name=$_POST['name']; $em=$_POST['mail']; $query="SELECT pw FROM user WHERE uname='$name' AND email='$em'" or die (mysql_error()); $result= mysql_query($query); $row = mysql_fetch_assoc($result); $pass=$row['pw']; $to="$em"; $from="From: passwords@MBD.net"; $msg="Username: $name\r\n"; $msg .="Password: $pass\r\n"; $msg .="Please keep this password safe"; $subject="Your Login Password\r\n"; mail($to,$subject,$msg,$from); header( "Location:messages.php?msg=2" ); exit(); ?> config.php is just my database connection info, which is working fine as it runs all all my pages that access the database. Thanks Tom I am working on an email extractor script that will extract emails from a site. I have a working script that will extract them from a single URL, but what I need it to do is to follow the links on the page. Here is my email script: <?php $the_url = isset($_REQUEST['url']) ? htmlspecialchars($_REQUEST['url']) : ''; ?> <form method="post"> Please enter full URL of the page to parse (including http://):<br /> <input type="text" name="url" size="65" value="http://<?php echo str_replace('http://', '', $the_url); ?>"/><br /> or enter text directly into textarea below:<br /> <textarea name="text" cols="50" rows="15"></textarea> <br /> <input type="submit" value="Parse Emails" /> </form> <?php if (isset($_REQUEST['url']) && !empty($_REQUEST['url'])) { // fetch data from specified url $text = file_get_contents($_REQUEST['url']); } elseif (isset($_REQUEST['text']) && !empty($_REQUEST['text'])) { // get text from text area $text = $_REQUEST['text']; } // parse emails if (!empty($text)) { $res = preg_match_all( "/[a-z0-9]+([_\\.-][a-z0-9]+)*@([a-z0-9]+([\.-][a-z0-9]+)*)+\\.[a-z]{2,}/i", $text, $matches ); if ($res) { foreach(array_unique($matches[0]) as $email) { echo $email . "<br />"; } } else { echo "No emails found."; } } ?> <!-- Email Extractor END --> It's a bit rough and quirky, but it works for a single URL. Here is the email extractor in action: http://www.site-search.org/email-extractor.php My ideal solution would be to combine this script with my URL extactor/link-extractor script: <!-- URL Extractor BEGIN --> <?php // findlinks.php // php code example: find links in an html page // mallsop.com 2006 gpl echo "<form method=post action=\"$PHP_SELF\"> \n"; echo "<p><table align=\"absmiddle\" width=\"100%\" bgcolor=\"#cccccc\" name=\"tablesiteopen\" border=\"0\">\n"; echo "<tr><td align=left>"; if ($_POST["FindLinks"]) { $urlname = trim($_POST["urlname"]); if ($urlname == "") { echo "Please enter a URL. <br>\n"; } else { // open the html page and parse it $page_title = "n/a"; $links[0] = "n/a"; //$meta_descr = "n/a"; //$meta_keywd = "n/a"; if ($handle = @fopen($urlname, "r")) { // must be able to read it $content = ""; while (!feof($handle)) { $part = fread($handle, 1024); $content .= $part; // if (eregi("</head>", $part)) break; } fclose($handle); $lines = preg_split("/\r?\n|\r/", $content); // turn the content into rows // boolean $is_title = false; //$is_descr = false; //$is_keywd = false; $is_href = false; $index = 0; //$close_tag = ($xhtml) ? " />" : ">"; // new in ver. 1.01 foreach ($lines as $val) { if (eregi("<title>(.*)</title>", $val, $title)) { $page_title = $title[1]; $is_title = true; } if (eregi("<a href=(.*)</a>", $val, $alink)) { $newurl = $alink[1]; $newurl = eregi_replace(' target="_blank"', "", $newurl); $newurl = eregi_replace(' rel="nofollow"', "", $newurl); $newurl = eregi_replace(" title=\"(.*)\"","", $newurl); $newurl = trim($newurl); $pos1 = strpos($newurl, "/>"); if ($pos1 !== false) { $newurl = substr($newurl, 1, $pos1); } $pos2 = strpos($newurl, ">"); if ($pos2 !== false) { $newurl = substr($newurl, 1, $pos2); } $newurl = eregi_replace("\"", "", $newurl); $newurl = eregi_replace(">", "", $newurl); //if (!eregi("http", $newurl)) { // local // $newurl = "http://".$_SERVER["HTTP_HOST"]."/".$newurl; // } if (!eregi("http", $newurl)) { // local $pos1 = strpos($newurl, "/"); if ($pos1 == 0) { $newurl = substr($newurl, 1); } $newurl = $urlname."/".$newurl; } // put in array of found links $links[$index] = $newurl; $index++; $is_href = true; } } // foreach lines done echo "<h2>Extracted Links</h2>\n"; echo "<p><b>Page Summary</b><br>\n"; echo "<b>Url:</b> ".$urlname."<br>\n"; if ($is_title) { echo "<b>Title:</b> ".$page_title."<br>\n"; } else { echo "No title found<br>\n"; } echo "<b>Links:</b><br>\n"; if ($is_href) { foreach ($links as $myval) { echo "<a href=\"$myval\">".$myval."</a><br>\n"; } } else { echo "No links found<br>\n"; } echo "End</p>\n"; } // fopen handle ok else { echo "<br>The url $urlname does not exist or there was an fopen error.<br>"; } echo "<br /><br /><h4><a href=\"http://www.site-search.org/url-extractor.php\" title=\"Link Extractor\">Try Again</a></h4>"; } // end else urlname given } // else find links now submit else { $urlname = ""; // or whatever page you like echo "<br /><br />\n"; echo "<p><h2>Link Extractor</h2><br>\n"; echo "File or URL: <input type=\"TEXT\" name=\"urlname\" value=\"http://\" maxlength=\"255\" size=\"80\">\n"; echo "<input type=\"SUBMIT\" name=\"FindLinks\" value=\"Extract Links\"></font><br></p> \n"; echo "<br /><br />\n"; } echo "</td></tr>"; echo "</table></p>"; echo "</form></BODY></HTML>\n"; ?> <!-- URL Extractor END --> Her e is the script in action: http://www.site-search.org/url-extractor.php Hi guys, I am writing the php script to send the email. I have noticed when I picked up on my email, I can see that it have been covered with mailed-by: myservername.com. I want to hide it, but I can't find a way to get it resolve. Here's the code: <?php session_start(); define('DB_HOST', 'localhost'); define('DB_USER', 'myusername'); define('DB_PASSWORD', 'mypass'); define('DB_DATABASE', 'mydbname'); $errmsg_arr = array(); $errflag = false; $link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD); if(!$link) { die('Failed to connect to server: ' . mysql_error()); } $db = mysql_select_db(DB_DATABASE); if(!$db) { die("Unable to select database"); } function clean($var){ return mysql_real_escape_string(strip_tags($var)); } $name = clean($_GET['name']); $email = clean($_GET['email']); $type = clean($_GET['type']); $comments = clean($_GET['comments']); if($name == ''){ $errmsg_arr[] = 'name are missing.'; $errflag = true; } elseif($email == ''){ $errmsg_arr[] = 'email are missing.'; $errflag = true; } if($errflag) { $_SESSION['ERRMSG_ARR'] = $errmsg_arr; echo implode('<br />',$errmsg_arr); } else { $insert = array(); if(isset($_GET['name'])) { $insert[] = 'name = \'' . clean($_GET['name']) .'\''; } if(isset($_GET['email'])) { $insert[] = 'email = \'' . clean($_GET['email']) . '\''; } if(isset($_GET['type'])) { $insert[] = 'type = \'' . clean($_GET['type']) . '\''; } if(isset($_GET['comments'])) { $insert[] = 'comments = \'' . clean($_GET['comments']) . '\''; } if (count($insert)>0) { $names = implode(',',$insert); if(isset($email)){ $name = $_GET['name']; $email = $_GET['email']; $header = "From: $name <$email>". "\r\n"; $to = "myname@myemail.com"; $subject = $type; $message = "$comments & $rate"; $header .= "MIME-Version: 1.0\l\n"; $add = "<$email>"; mail($to, $subject, $message, $header, $add); echo "Thank you for sent us your email"; } } } ?> I guess that something got to do with this: if(isset($email)){ $header = "From: $name <$email>". "\r\n"; $header .= "MIME-Version: 1.0\l\n"; $add = "<$email>"; } I have disabled the safe-mode, so do you know how I can hide the mailed-by header using with the code on above?? Any advice would be much appreciate. Thanks in advance. Iwant to make a contact us script and here is done so far. I am almost sure its about preg match filters but cant find a solution why it doesnt work. Appreciate any help. Here is my code: $first_name = $_POST['first_name']; $last_name = $_POST['last_name']; $email_from = $_POST['email']; $comments = $_POST['comments']; $emailtrue = '/^([A-Za-z0-9-_]+@[A-Za-z0-9-_]+\.[A-Za-z]{2,4})$/'; $nametrue = "/^[A-Za-z]+$/D"; if(!preg_match($nametrue,$first_name)) { echo "The First Name you entered does not appear to be valid."; die (); } if(!preg_match($nametrue,$last_name)) { echo "The Last Name you entered does not appear to be valid."; die (); } if(!preg_match($emailtrue,$email_from)) { echo "The Email Address you entered does not appear to be valid."; die (); } if(strlen($comments) < 4) { echo "The Comments you entered do not appear to be valid. Min. 4 letters." ; die (); } $to = xxxxxxxxxx.com'; $subject = 'User Email'; $headers = 'From: '.$email_from. "\r\n" . 'Reply-To: '.$email_from. "\r\n" . 'X-Mailer: PHP/' . phpversion(); mail($to, $subject, $comments, $headers); Hi Everyone, I read a few things before having posted this. I think I am in the right place; but as a caveat, please correct me if I am in the wrong place. At any rate, I am a designer who is just learning to code in php. I am studying on my own, now. This is only my second post here, and I don't know what I am doing. I have never written an email script before and very little of what I have seen makes sense to me, as yet. I would like to: 1.) have the "Is this urgent?" checkbox checked if the user selects either: a.) I am a Journalist b.) Received wrong order c.) Order not received d.) Credit Card Issue 2.) Send this email The code is below. Code: [Select] <div id="form"> <form id="contact" method="post" action="contactForm.php"> <div class="fields"> <fieldset> <!--this is the name field--> <label for="name"><span>Name</span> <input type="text" name="name" id="name" /> </label> <!--end of the name field--> <!--this is the email field--> <label for="email"><span>Email</span> <input type="text" name="email" id="email" /> </label> <!--end of the email field--> <!--this is the telephone field--> <label for="telephone"><span>Telephone</span> <input type="text" name="telephone" id="telephone" /> </label> <!--end of the telephone field--> </fieldset> </div> <fieldset> <!--this is the reason menu--> <label for="reasonMenu"><span>Reason for contact</span> <select id="reasonMenu"> <option selected="selected" value="choose">Please Choose</option> <option value="general">General Inquiry</option> <option value="designer">I am a Journalist</option> <option value="corporate">Corporate Gifts</option> <option value="item">Item Request</option> <option value="designer">I am a Designer</option> <option value="supplier">I am a Supplier Rep</option> <option value="vip">VIP Candi Ladies</option> <option value="orderNot">Order Not Received</option> <option value="orderWrong">Received Wrong Order</option> <option value="credit">Credit Card Issue</option> </select> </label> <!--end of the reason menu--> <!--this is the item number field--> <label for="item"><span>Item Number?</span> <input type="text" name="item" id="item" /> </label> <!--end of the item number field--> </fieldset> <fieldset> <!--this is the message box--> <label for="message"><span>Message</span> <textarea name="message" rows="10" cols="25" id="message"> Please type your message here. </textarea> </label> <!--end of the message box--> <!--this is the urgent checkbox--> <!--<div id="checkbox">--> <span id="urgent">Is This Urgent?</span> <label for="checkbox" id="checkbox"> <input type="checkbox" name="checkbox" value="URGENT!" id="checkbox" /> </label> <!--</div>--> <!--end of the urgent checkbox--> </fieldset> <!--this is the submit button--> <div id="sendBtn"> <input type="submit" value="Send This Form" /> </div> <!--end of the submit button--> <!--this is the reset button--> <div id="clearBtn"> <input type="reset" value="Clear The Form" /> </div> <!--end of the reset button--> <!--end of the message box--> </form> Thank you all in advance for your help. I've sent test to server and verified that email working. New with PHP so assuming my code is wrong.
Attached Files
contact.html 22.48KB
0 downloads
contact_script.php 3.5KB
3 downloads Can someone show me a simple mail script that I can run in cli, I can enter a $to = email@email.com and then have it send to my email? just in cli.. Thanks Hi everybody, I want to create a script which will send SMS on a number once new mail arrives in email account. I have SMS API service from http://www.freesmsapi.com/ I am using cPanel, but how to do it ? One idea is, new mails are stored in "new" folder and already read mails are stores in "cur". So once, new email file will come in "new" folder PHP script will see that file and will send SMS, with text as "Hi, {user}, you gotta mail from {sender}, subject is {sibject}" That PHP file will be added to Cronjobs. But how to do it ? I have been searching on this issue from many months, did google but no answer. I need help |