PHP - Need A Mail Receiving Client
I want some code to receive email, reformat and then forward to another email address
I'm not sure where to start with this
Does the application need to be constantly running - monitoring incoming emails?
What is involved?
I did a search and saw many discussions saying that Google App Engine was available for usage
I've no experience of this
Just looking for suggestions
Thanks
OM
Similar TutorialsHi all, I'm coding an automated mailer for a dentist office. They set appointment dates through a web interface, and then this appointment is mailed to the customer via PHP's mail() function. However, some users are not receving the mail. They claim that it is not even in the junk mail folder. Is it because I'm setting or not setting certain properties in the header? Should I be setting something else? Here is my code Code: [Select] ini_set("SMTP", "mail.isp-provider.net"); $headers = 'From: Schedule Manager <schedule@address.com>' . "\r\n" . 'Reply-To: Schedule Manager <schedule@address.com>' . "\r\n" . 'Bcc: internal@address.com' . "\r\n" . 'Content-type: text/html; charset=iso-8859-1' . "\r\n" . 'X-Mailer: PHP/' . phpversion(); mail($customerAddress, $subject, $body, $headers); Note that customerAddress, subject, and body are all just regular normal strings. As I said, it works for most customers, but some customers do not receive the emails. Hello, Below is my existing code for my web site visitor to fill out the form... they see a thank you html page.... and I get the info inserted into my database.... and I get an e-mail with all their details, even their date of registration. From what I have seen so far, EVERYTHING WORKS SUCCESSFULLY. HOWEVER, I would like to have the web site visitors details that they filled out ALSO SENT BACK to the web site visitor as a confirmation... say that this is a confirmation of the form they previously filled out. How do I accomplish this based off of my existing code here? I also would like my thank you.html code at the bottom of my current php code to be called in from a SEPARATE REDIRECT thankyou.php page after a successful form entry. I know that ALL headers must be IMMEDIATELY taken cared of upon entering any php page. This is what i used ***** header("Location: thankyou.php");******* Now I know that this is the correct code to make this happen but i do not know how to get this to work with my present code here. How do put the header location: thank you.php code in my EXISTING PHP page to make this all work right? thanks mrjap1 Code: [Select] ====================== HTML ========================== <?php require_once("db_connection.php");?> <!DOCTYPE HTML> <html lang="en"> <head> <meta charset="UTF-8"> <title>HTML form for insert users</title> <style type="text/css"> p { margin:0; padding:0; font-family:Arial, Helvetica, sans-serif; font-size:12px; color:#633; font-weight:bold; } legend { font-family:Arial, Helvetica, sans-serif; font-size:15px; color:#3F6; font-weight:bold; } #form_container { background:#F7F; margin: 50px auto 50px auto; border: 1px solid #F00; padding:10px; width:285px; height:150px; } input { margin-bottom:5px; } body { background-color: #033; } </style> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> </head> <body> <?php if (isset($_POST['submit'])) { // Handle the form. $message = NULL; // Create an empty new variable. // Check for a first name. if (empty($_POST['first_name'])) { $first_name = FALSE; $message .= '<p>You forgot to enter your first name... its Required!</p>'; } else { $first_name = ($_POST['first_name']); } // Check for a last name. if (empty($_POST['last_name'])) { $last_name = FALSE; $message .= '<p>You forgot to enter your last name... its Required!</p>'; } else { $last_name = ($_POST['last_name']); } // Check for an email address. if (empty($_POST['email'])) { $email = FALSE; $message .= '<p>You forgot to enter your email address... its Required!</p>'; } else { $email = ($_POST['email']); } } ?> <div id="form_container"> <form action="form_proceessed201XXX.php" method="post"> <input type="hidden" name="submit" value="true" /> <fieldset> <legend>My Data Feilds</legend> <!-- ### FIRST NAME ### --> <p> <label>First Name:</label><input name="first_name" type="text" value="<?php if(isset($_POST['first_name'])) echo $_POST['first_name']; ?>" id="first_name" size="15" maxlength="30"> </p> <!-- ### LAST NAME ### --> <p> <label>Last Name:</label><input name="last_name" type="text" value="<?php if(isset($_POST['last_name'])) echo $_POST['last_name']; ?>" id="last_name" size="15" maxlength="30"> </p> <!-- ### EMAIL ### --> <p> <label>E-mail:</label><input name="email" type="text" value="<?php if(isset($_POST['email'])) echo $_POST['email']; ?>" id="email" size="15" maxlength="30"> </p> <!-- ### SUBMIT BUTTON ### --> <p style="text-align:center"> <input type="submit" name="submit" value="SEND MY INFO PLEASE" /> </p> </fieldset> </form> </div> </body> </html> ====================== PHP ========================== <?php // ALL THE SUBJECT and EMAIL VARIABLES $emailSubject = 'MY TEST EMAIL SCRIPTING!!! '; $webMaster = 'myemail@gmail.com'; // GATHERING the FORM DATA VARIABLES $first_name = $_POST['first_name']; $last_name = $_POST['last_name']; $email = $_POST['email']; $registration_date = $_POST['registration_date']; $date = date ("l, F jS, Y"); $time = date ("h:i A"); $body = <<<EOD <br /><hr><br /> <strong>First Name:</strong> $first_name <br /> <strong>Last Name: </strong>$last_name <br /> <strong>Email:</strong> $email <br /> <strong>Registration Date:</strong> $date at $time <br /> EOD; // THIS SHOW ALL E-MAILED DATA, ONCE IN THE E-MAILBOX AS READABLE HTML $headers = "From: $email\r\n"; $headers .= "Content-type: text/html\r\n"; $success = mail($webMaster, $emailSubject, $body, $headers); // THE RESULTS OF THE FORM RENDERED AS PURE HTML $theResults = <<<EOD <!DOCTYPE HTML> <html lang="en"> <head> <style type="text/css"> body { font-family:Arial, Helvetica, sans-serif; font-size:11px; font-weight:bold; } #thankyou_block { width: 400px; height: 250px; text-align:center; border: 1px solid #666; padding: 5px; background-color: #0CF; border-radius:8px; -webkit-border-radius:8px; -moz-border-radius:8px; -opera-border-radius:8px; -khtml-border-radius:8px; box-shadow:0px 0px 10px #000; -webkit-box-shadow: 0px 0px 10px #000; -moz-box-shadow: 0px 0px 10px #000; -o-box-shadow: 0px 0px 10px #000; margin: 25px auto; } p { font-family: Arial, Helvetica, sans-serif; font-size: 14px; line-height: 18px; letter-spacing:1px; color: #333; } </style> <meta charset="UTF-8"> <title>THANK YOU!!!</title> </head> <body> <div id="thankyou_block"> <br><br><br> <h1>CONGRATULATIONS!!</h1> <h2>YOUR FORM HAS BEEN PROCESSED!!!</h2> <p>You are now registered in our Database...<br> we will get back to you very shortly.<br> Please have a very wondeful day.</p> </div> </body> </html> EOD; echo "$theResults"; ?> I have a notification system that notifies users of new comments, inside the email I have images, some of the logo, some of different people, everything shows up fine on my computer (yahoo email), however in the iPhones email application no images show up, there are just the blue squares with the question marks in them. I'm not sure what I'm missing. Code: [Select] $from = "Kithell <notifications@kithell.com>"; $headers = "From:" . $from ."\r\n"; $headers .= 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; $subject = name($from_id, 'fl').$action; $message = '<html><body> <style>@charset "utf-8"; /* CSS Document */ .e-container { background-color: #FFF;position: relative;width: 90%;min-height:1px;margin-right: auto;margin-left: auto; } .e-container .e-m-header { padding: 2px; background-image: url(http://www.kithell.com/assets/tall-grey-header.png); background-repeat: repeat-x; border: 1px solid #CCC; background-position: bottom; display: block; text-align: center; } .e-container p { font-family: Arial, Helvetica, sans-serif; font-size: 12px; font-weight: normal; color: #666; vertical-align: text-top; display: inline-block; } .e-container .e-usr-photo { display: inline-block; margin: 10px; float: left; background-color: #F4F4F4; } .e-container p a { font-weight: bold; color: #3F60A3; text-decoration: underline; padding: 0px; float: left; margin-top: 0px; margin-right: 5px; margin-bottom: 0px; margin-left: 0px; } .e-container .e-quotes { font-size: 20px; font-weight: bold; color: #999; font-family: Tahoma, Geneva, sans-serif; display: block; padding: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 75px; margin-top:10px; } .e-container .e-message { font-size: 13px; color: #333; padding: 0px; margin-top: 0px; margin-right: 10px; margin-bottom: 0px; margin-left: 10px; clear: none; display: inline; }</style> <div class="e-container"><div class="e-m-header"><img src="http://www.kithell.com/assets/kithell-logo.png" /></div><img class="e-usr-photo" src="http://www.kithell.com/'.photo($from_id, 55).'" /><br /><p><a target="_blank" href="http://www.kithell.com/#/profile&id='.$from_id.'">'.name($from_id, "fl").' </a> '.$action.'<div class="e-quotes">"<p class="e-message">'.nl2br(htmlentities(stripslashes($message))).'</p>"</div></p></div></body></html>'; mail($to,$subject,$message,$headers); This topic has been moved to Other Web Server Software. http://www.phpfreaks.com/forums/index.php?topic=347009.0 I wish to create validation rules once which are used both on the client and on the server.
For instance, I will start off with the following PHP object:
stdClass Object ( [rules] => stdClass Object ( [email] => stdClass Object ( [required] => 1 [email] => 1 [remote] => stdClass Object ( [url] => check-email.php [type] => post [data] => stdClass Object ( [username] => function() {return $( '#username' ).val();} ) ) ) ) [messages] => stdClass Object ( [email] => stdClass Object ( [required] => an email is required ) ) )When the edit page is downloaded to the client, I will include this object in some format suitable to the client. The client will then use the jQuery Validation plugin (http://jqueryvalidation.org/) along with the validation object, and client side validate the page. When the form passes client side validation and is uploaded, PHP will use the same validation object to serverside validate the form (I have this part working as desired). My question is how should I pass this data to the client? Originally, I would just use PHP to write some JavaScript. exit('var myObj='.json_encode($myObj));Note that when I json_encode the object, the value of $myObj->rules->email->remote->data->username is a string with quotes around it, however, I can easily use PHP to strip these tags before sending it to the client. As Jacques1 pointed out in http://forums.phpfre...ascript-client/, I should never ever use PHP to generate JavaScript, and should use AJAX to download the JSON directly. I tried doing the later, but found that a callback function could not be included in the JSON. Please advise on the best way to accomplish this. Thank you My specific situation is SEOMoz, but this is a general question. I have a pretty extensive series of tools that rely on the SEOMoz api. They recently implemented 1 request per 10 seconds throttle limit. Is there a way I can run one request, stop for 10 seconds, and run the next, and so on? Anyway to get around something like this, without breaking their TOS? Hi, I have products page which products page and I am echoing the ID of each product into a link with the description of the product as the anchor text. Code: [Select] <a href="product.php?ID=<?php echo $row['ID']; ?>" class='productlink' ><?php echo $row['description']; ?></a> However I am struggling to Get the information from the receiving 'product.php' page. The code I have on the product.php page is as follows: Code: [Select] <?php $ID = 0; if (isset($_GET['ID'])) { $ID = $_GET['ID']; } ?> <?php echo $_GET['price']; // outputs: 1 ?> However nothing is being echoed out. I just a blank screen. Am I missing like capital letters. My column is title 'ID'. Do I need to query the database in someway on the receiving page or do I just use a different GET code? Hi everyone, First off I have to mention I'm a newbie so my php knowledge is limited -sorry, but this is why I turn to you guys. I have a basic emailform.php= a field into which the user inputs his email address and I should be getting some sort of a message announcing me he signed up. But the last part isn't happening - I've tried emails from yahoo, gmail and from the sitedomain itself. Also I've tried these emails in the php form itself (email to section). I also gotta mention I may have deleted a php.ini file from the root server (I don't really remember exactly). Hosting is with godaddy (I know it sux but please bear with me.) Also my website is not in English so I need special characters (so it's UTF8). I'd be so grateful if you could help me out here - in return I'm offering a drink if you're ever in the vicinity of Milan (Italy) and my permanent respect to the world of programmers EMAILFORM.PHP Code: [Select] <?php if(isset($_POST['email'])) { // EDIT THE 2 LINES BELOW AS REQUIRED $email_to = "ajutor@t-ajutam.net"; $email_subject = "New e-mail subscriber"; function died($error) { // your error code can go here echo "We are very sorry, but there were error(s) found with the form your submitted. "; echo "These errors appear below.<br /><br />"; echo $error."<br /><br />"; echo "Please go back and fix these errors.<br /><br />"; die(); } // validation expected data exists if (!isset($_POST['email'])) { died('We are sorry, but there appears to be a problem with the email your submitted.'); } $email_from = $_POST['email']; // required $error_message = ""; $email_exp = "^[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$"; if(!eregi($email_exp,$email_from)) { $error_message .= 'The Email Address you entered does not appear to be valid.<br />'; } if(strlen($error_message) > 0) { died($error_message); } $email_message = "Form details below.\n\n"; function clean_string($string) { $bad = array("content-type","bcc:","to:","cc:","href"); return str_replace($bad,"",$string); } $email_message .= "Email: ".clean_string($email_from)."\n"; // create email headers $headers = 'From: ajutor@t-ajutam.net'; 'Reply-To: '.$email_from."\r\n" . 'X-Mailer: PHP/' . phpversion(); @mail($email_to, $email_subject, $email_message, $headers); ?> <!-- include your own success html here --> Thank you for contacting us. We will be in touch with you very soon. <? } ?> and HTML index 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=utf-8" /> <title>T-ajutăm nu este încă gata. </title> <link rel="stylesheet" type="text/css" href="style.css" /> <script type="text/javascript" src="http://code.jquery.com/jquery-latest.pack.js"></script> <script type="text/javascript" src="js/jquery.countdown.js"></script> <script type="text/javascript" src="js/jcarousellite1.0.1_min.js"></script> <script type="text/javascript" src="http://w.sharethis.com/button/buttons.js"></script><script type="text/javascript">stLight.options({publisher:'83f9b168-ba78-4f14-af11-992f92dcf19b'});</script> <!-- jquery countdown--> <script type="text/javascript"> $(function () { var austDay = new Date(); austDay = new Date(austDay.getFullYear() + 2, 0, 0); $('#defaultCountdown').countdown({until: austDay, layout: '{dn} {dl}, {hn} {hl}, {mn} {ml}, and {sn} {sl}'}); $('#year').text(austDay.getFullYear()); }); </script> <!-- jquery slider --> <script type="text/javascript"> $(function() { $("#slidertext").jCarouselLite({ btnNext: ".next", btnPrev: ".prev" }); }); </script> <!--script for IE6-image transparency recover--> <!--[if IE 6]> <script type="text/javascript" src="js/DD_belatedPNG_0.0.7a-min.js"></script> <script> /* EXAMPLE */ DD_belatedPNG.fix('#logo img,#main,.counter,.twitter,.facebook,#submit_button,.prev img,.next img,#email_input'); </script> <![endif]--> <script type="text/javascript"> var _gaq = _gaq || []; _gaq.push(['_setAccount', 'UA-21856062-1']); _gaq.push(['_trackPageview']); (function() { var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); })(); </script> </head> <body> <div class="container"> <div id="header"> <div id="logo"> <a href="index.html"><img src="images/logo.png" alt="logo"/></a> </div><!--end logo--> <div id="contact_details"> <p><a href="mailto:ajutor@t-ajutam.net">Contact</a></p> </div><!--end contact details--> </div><!--end header--> <div style="clear:both"></div> <div id="main"> <div id="content"> <div class="text"> <h2>T-ajutăm nu este încă gata</h2> <br> <p><font color=#e5e5e5>Dacă ne laşi adresa ta de email mai jos te anunţăm când suntem gata.</font></p><br> </div><!--end text--> <div class="details"> <!--slider prev button--> <a class="prev" href="#"><img src="images/prev.png" alt="" /> </a> <div id="sliderwrap"> <div id="slidertext"><!-- The slider --> <ul style="margin: 0pt; padding: 0pt; position: relative; list-style-type: none; z-index: 1; width: 6600px; left: -3000px;"> <li> <h3>Introdu adresa ta de email</h3> <!-- <form action="emailhandler.php" method="post" id="email"> <div id="submitwrapper"> <div ><input type="text" name="email" size="30" value="Enter Your E-mail" onfocus="if(this.value=='Enter Your E-mail'){this.value=''};" onblur="if(this.value==''){this.value='Enter Your E-mail'};" id="email_input" /> </div> <div ><input type="submit" name="Submit" value="Submit" border="none" id="submit_button"/> </div> </div> </form> --> <form method="post" id="subscribeform" action="emailform.php"> <p> <div id="email_input"><input name="email" type="text" size="30" value="Enter Your E-mail" onfocus="if(this.value=='Enter Your E-mail'){this.value=''};" onblur="if(this.value==''){this.value='Enter Your E-mail'};" id="email" /> <input type="submit" id="submit_button" value="Submit" size="80" /> </div> <br /> </p> </form> </li><!-- Slider item --> <li> <h3>T-ajutăm este un nou concept de donaţii online</h3> <p>Ai nevoie de ajutor? Vrei să ajuţi dar nu ştii cum ?<p> <br> <p>Ai ajuns la locul potrivit.</p> </li><!-- Slider item --> <li> <h3>Fii la curent: urmăreşte-ne pe facebook sau twitter</h3> <div class="social"> <a class="twitter" href="http://twitter.com/t_ajutam"></a> <a class="facebook" href="http://www.facebook.com/pages/T-ajutam/178280318883554"></a> </div> </li><!-- Slider item --> <li> <h3>Ţi se pare interesant? Trimite linkul şi prietenilor tăi </h3> <span class="st_twitter_vcount" displayText="Tweet"></span><span class="st_facebook_vcount" displayText="Share"></span><span class="st_email_vcount" displayText="Email"></span><span class="st_sharethis_vcount" displayText="Share"></span> </li><!-- Slider item --> </ul> </div><!-- End of slidertext --> </div><!-- End of sliderwrap --> <!--slider next button--> <a class="next" href="#"><img src="images/next.png" alt=""/></a> </div><!--end details--> </div><!--end content--> </div><!--end main--> <div id="footer"></div> <!-- Footer start --> <p>Powered by <a href="http://ourtuts.com">ourtuts.com</a></p> <!-- Footer end --> </div><!--end class container--> </div> </body> </html> i have a shopping cart set up with mysql with a $_COOKIE['cart_id'] used to call all rows with cart_id... i have a while loop print out all the items in the cart $sql2 = mysql_query("SELECT * FROM cart WHERE cart_id = '$cart_id'") or die(mysql_error()); while($row = mysql_fetch_array($sql2)){ then i have it echo out the name...desc... quantity of each item... but the quantity is set up to be able to change and i have a form set up and i'd like to have each item be able to be changed at once if they wanted....but being multiple rows... there could be multiple $_POST['quantity']... echo "<td><input type='text' name='quantity' value='".$quantity."'/></td>"; there is a unique id for each row in the table that i'd like to set up with an array to post... i'd like to set up an array $array[$uniq_id] => $quantity; and somehow POST this array name='$array[]' and then on the action end... be able to call it by having foreach($quantity as $uniq_id => $qty){ mysql_query("UPDATE cart SET quantity='$qty' WHERE id='$uniq_id' "); } i'm not sure if i'm approaching this the right way... the array part is leaving me stuck...any help is appreciated..thank you! I'm using the example_form from securimage. I have modified the email address in the php script to my email address and uploaded everything to my hosting company's FTP server. I then fill out the form and click the submit message button and the form says "The captcha was correct and the message has been sent!" but I never receive the email. I have other basic php forms that work just fine just for some reason I can't get this one working. Could someone please let me know if I'm missing something here? Thanks Hi all, I should first mention I'm not much of a coder, I'm using PHP to create a custom weather solution for myself. Basically am pulling XML from weather.gov and working with the data. So far, so good. I'm getting the data I want displayed correctly, but noticed when I refresh the page I sometimes receive old data. (From the past hour, two hours, etc.) I figured this was cached info and I'm trying to figure out how to clear that out. This is how I'm accessing the XML: $url = 'http://forecast.weather.gov/MapClick.php?lat=40.65160&lon=-74.34420&FcstType=digitalDWML'; $xml = file_get_contents($url); I did some research and tried the following headers, but that doesnt seem to work: <?php header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); header("Cache-Control: no-cache"); header("Pragma: no-cache"); ?> Also tried appending a random number onto the $url, (as per a forum question/response somewhere) but that didn't work. Anyone suggestions would be great. Thanks Good day i am not receiving emails when hitting submit; not sure if my code is correct. jtconfirmation.co.za <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Names Confirmation RSVP</title> <link rel="stylesheet" href="church.css"> </head> <body> <form action="/mail_form.php" method="POST" id="church-form"> <div class="top"> <nav> <a href="index.html" class="mybutton">Home</a> </nav> </div> <div class="form"> <div class="info"> <h1>RSVP</h1> <h2>for the Confirmation Service of</h2> <h1>Name</h1> <p class="line">________________________________________</p> <h2>The Details</h2> <p>Sunday, 28 February 2021</p> <p>10:00 AM</p> <p>Please RSVP by 15 February 2021</p> <h2>Confirmation Service</h2> <p><a href="#" target="_blank"> Calvyn Protestant Church Diep River</a></p> <p>10 Keswick St, Elfindale</p> <p class="line">________________________________________</p> <input type="text" value="name" placeholder="Name"> <input type="email" value="email" placeholder="Email"> </div> <?php echo((!empty($errorMessage)) ? $errorMessage : '') ?> <button type="submit" class="accept" value="Send">Accept</button> <button type="submit" class="regret" value="Send">Regret</button> </div> </form> <script src="//cdnjs.cloudflare.com/ajax/libs/validate.js/0.13.1/validate.min.js"></script> <script> const constraints = { name: { presence: {allowEmpty: false} }, email: { presence: {allowEmpty: false}, email: true } }; const form = document.getElementById('church-form'); form.addEventListener('submit', function (event) { const formValues = { name: form.elements.name.value, email: form.elements.email.value }; const errors = validate(formValues, constraints); if (errors) { event.preventDefault(); const errorMessage = Object .values(errors) .map(function (fieldValues) { return fieldValues.join(', ') }) .join("\n"); alert(errorMessage); } }, false); </script> </body> </html> s <?php use PHPMailer\PHPMailer\PHPMailer; require __DIR__ . '/vendor/autoload.php'; $errors = []; $errorMessage = ''; if (!empty($_POST)) { $name = $_POST['name']; $email = $_POST['email']; if (empty($name)) { $errors[] = 'Name is empty'; } if (empty($email)) { $errors[] = 'Email is empty'; } else if (!filter_var($email, FILTER_VALIDATE_EMAIL)) { $errors[] = 'Email is invalid'; } if (!empty($errors)) { $allErrors = join('<br/>', $errors); $errorMessage = "<p style='color: red;'>{$allErrors}</p>"; } else { $mail = new PHPMailer(); // specify SMTP credentials $mail->isSMTP(); $mail->Host = 'smtp.gmail.com'; $mail->SMTPAuth = true; $mail->Username = 'name@example.com'; $mail->Password = 'P@ssword123'; $mail->SMTPSecure = 'tls'; $mail->Port = 587; $mail->setFrom($email, 'Mailtrap Website'); $mail->addAddress('piotr@mailtrap.io ', 'Me'); $mail->Subject = 'RSVP Church'; // Enable HTML if needed $mail->isHTML(true); $bodyParagraphs = ["Name: {$name}", "Email: {$email}", "Message:", nl2br($message)]; $body = join('<br />', $bodyParagraphs); $mail->Body = $body; echo $body; if($mail->send()){ header('Location: thank-you.html'); // redirect to 'thank you' page } else { $errorMessage = 'Oops, something went wrong. Mailer Error: ' . $mail->ErrorInfo; } } } ?>
I am trying to retrieve certain keys of a post array. I am sending a payment form with a dynamic number of product id's. I will never know how many product id's will be sent for each order. When the post array returns the values to my script it returns them as: Code: [Select] $_POST['product_id_1'], $_POST['product_id_2'], etc. How would I be able to extract all post array keys that start with "product_id_? Here is what I was thinking earlier, but it doesn't work. Code: [Select] $i = 1; foreach ($_POST['product_id_' . $i] as $product) { $productId = $product['product_id_' . $i]; $queryInsert = mysql_query("INSERT INTO video_purchase (video_purchase_purchase_id, video_purchase_video_id) VALUES ($purchaseId, $productId)", $connect) or die(mysql_error()); $i++; } Apologies, first off: I only venture into PHP occasionally and my problem is something very very obvious... The data I'm getting back from the script below differs radically from the data recovered by the same SQL applied directly in phpMyAdmin. $sql = mysql_query('SELECT `fid` , `title` , `extension` FROM files WHERE `mid_FK` = 2353 ORDER BY `title`') or die ("Sorry: cannot retrieve files."); $files_found = mysql_fetch_array($sql); $num_files_found = count($files_found); The native SQL returns three rows from the table, all with entries in each column. What my script produces as relevant variables is this. Code: [Select] [sql] => Resource id #6 [files_found] => Array ( [0] => 961 [fid] => 961 [1] => Abstract of Case [title] => Abstract of Case [2] => doc [extension] => doc ) [num_files_found] => 6 This is the first row of the SQL results, duplicated. Whereas what I need are the entries for all three rows. I'm baffled, not least because I copied it out of another script I wrote last time I was doing this sort of thing, which has been working fine ever since. I have some data I'm posting from Swift to my php file via x-www-form-urlencoded. How can I decode this POST data? $to=sammieave@ave.com,samuel@ave.com; $subject = "New Event Logged"; $message = "Test"; $headers = "From: Samuel<sammieave@ave.com>;\r\n"; $headers .= "Content-Type: text/html"; mail($to,$subject,$message,$headers); I am having the above code but unfortunately the error I am getting is: Warning: mail() [function.mail]: SMTP server response: 550 Requested action not taken: mailbox unavailable or not local in C:\xampp\htdocs\CRM\support\mailer.php on line 139 Hi there I am trying to send an array of items to delete from a form, receive them back to the page then enter them into another form and then send them back to the page. Basically its a delete then confirm delete thing. So I can send the array from the first form though I am not sure how to place them into the second (confirm delete) form. What I've got so far considering the array does get sent in the first place is First I receive the array: if (isset($_POST['delete'])) { if (isset($_POST['todelete'])){ $todelete[] = ($_POST['todelete']);////here is my problem I think echo <<<_END <div>Are you sure you wish to make these changes</div> <div><form action="" method="post"> <input type='hidden' name='todelete'value="$todelete"/> <input type='hidden' name='confirm'value="confirm"/> <input id='inputform' type='submit' size='50' value='Yes' /> </form> <form action="" method="post"> <input type='hidden' name='rollback'value='rollback' /> <input id='inputform' type='submit' size='50' value='No' /> </form></div> _END; } } Then I try and receive the array back with if (isset($_POST['confirm'])){ foreach ($_POST['todelete'] as $delete_id) { $query ="DELETE FROM gallery WHERE id = $delete_id"; $result=mysql_query($query) or die("Invalid Query : ".mysql_error()); echo "Removing Data"; } } What I receive is a warning: 'Warning: Invalid argument supplied for foreach() in C:\wamp\www\css\enterphotos.php on line 91" I am sure that there is a simple solution! Can anyone help me here? I am being sent an XML feed which needs to be downloaded in a 'compressed way'.
The example I have been given is this:
$url = 'http://myurl.com'; $headers[] = "Accept-Encoding: gzip,deflate"; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); curl_setopt($ch, CURLOPT_BINARYTRANSFER, true); $data = curl_exec($ch); but the output I am getting is jargon like this with loads of black diamond question marks:� +T��sƒ���-}#v���]K���������HB�$&G�����Y�����'߷s�,�.4֫'?'���9;*9^��>�j~�ǫ}z|hq�J��Գ".o2)~b���U~I| How to a convert it back into XML? Many thanks Edited by samjsharples, 30 September 2014 - 03:49 PM. Hi I am really frustrated because I got my php code working fine and then I had to make some minor changes to my html form and now the php is not working. I am reciec=ving this message: Warning: move_uploaded_file(upload/carey.bmp) [function.move-uploaded-file]: failed to open stream: No such file or directory in /home/content/19/6550319/html/ipad/listing.php on line 35 Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move '/tmp/phpIEUQLo' to 'upload/carey.bmp' in /home/content/19/6550319/html/ipad/listing.php on line 35 Sorry, there was a problem uploading your file.03/10/11 : 20:50:08 I wrote it twice because it keeps coming out twice. I guess it means that it cant upload the image because there is no image but I really dont understand why. I havent changed the image part of the form. Does anyone have any ideas? It is much appreciated. Here is the code Code: [Select] <?php //This is the directory where images will be saved $target = "upload/"; $target = $target . basename( $_FILES['photo']['name']); //This gets all the other information from the form $price=$_POST['price']; $pic=($_FILES['photo']['name']); $pic2=($_FILES['phototwo']['name']); $pic3=($_FILES['photothree']['name']); $pic4=($_FILES['photofour']['name']); $description=$_POST['iPadDescription']; $condition=$_POST['condition']; $gig=$_POST['giga']; $yesg=$_POST['yesg']; $fname=$_POST['firstName']; $lname=$_POST['lastName']; $email=$_POST['email']; // Connects to your Database mysql_connect ("taken out for security", "taken out", "taken out") or die(mysql_error()) ; mysql_select_db("taken out") or die(mysql_error()) ; //Writes the information to the database mysql_query("INSERT INTO ipadlist (price,photo,phototwo,photothree,photofour,iPadDescription,condition,giga,yesg,firstName,lastName,email) VALUES ('$price', '$pic', '$pic2', '$pic3', '$pic4', '$description', '$condition', '$gig', '$yesg', '$fname', '$lname', '$email')") ; //Writes the photo to the server if(move_uploaded_file($_FILES['photo']['tmp_name'], $target)) { //Tells you if its all ok echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded, and your information has been added to the directory"; } else { //Gives and error if its not echo "Sorry, there was a problem uploading your file."; } echo date("m/d/y : H:i:s", time()) ?> This has probably been asked a bunch of times , but : I only recently started to self learn PHP , and this small project i am making is quite a challange for me. The scripts below are not realy writen by me , but i wished to tie them together to get a fully working code. What is suppose to happen is : In the form i wish to put a special button that puts extra input fields in the form. After the form is submited ,with whatever amount of feilds in it, the data goes to a processing.php file that sorts all the info gathered and finaly sends all this data formated in to the last file that will be inluded in the index.php. i already have the code for increcing the amount of inputs but the problem is , all inputs have the same names. Coz of that i get a mess. What i need is each input to have a unique name or id , that way the processing file would receive different names(id's) with different values(what ever is writen in the inputs by users). for example: I have 2 enitial fields displayed on form.html , i click the button "add new" 5 times and add 5 more input fields. All this data must be sent to a process.php and on the output write all of this information formated in the last file in a row that will be displayed in the index by useing <?include("blablabla.php");?> The input increment is done by a java script. the problem is sending data with unique id(name) and receiving it. The form file : <?include("header.php");?> <?$i = 1; ?> <script type="text/javascript"> function validate(frm) { var ele = frm.elements['feedurl[]']; if (! ele.length) { alert(ele.value); } for(var i=0; i<ele.length; i++) { alert(ele[i].value); } return true; } function add_feed() { var div1 = document.createElement('div'); // Get template data div1.innerHTML = document.getElementById('newlinktpl').innerHTML; // append to our form, so that template data //become part of form document.getElementById('newlink').appendChild(div1); } var ct = 1; function new_link() { ct++; var div1 = document.createElement('div'); div1.id = ct; // link to delete extended form elements var delLink = '<div style="text-align:right;margin-right:65px"><a href="javascript:delIt('+ ct +')">Del</a></div>'; div1.innerHTML = document.getElementById('newlinktpl').innerHTML + delLink; document.getElementById('newlink').appendChild(div1); } // function to delete the newly added set of elements function delIt(eleId) { d = document; var ele = d.getElementById(eleId); var parentEle = d.getElementById('newlink'); parentEle.removeChild(ele); } </script> <TABLE> <style> #newlink {width:600px} </style> <form action='sendorder.php' method='post'> <div id="newlink"> <div> <table align="center" border=0> <TR><TD><B>Product:</B> </TD><TD><input type=text name=prodname1 value="<?=$_GET['prodname1'];?>"> </TD> <TD><B>Price:</B> </TD><TD><input type=text name=price1 value="<?=$_GET['price1'].$curency;?>"><b>%</b></TD></TR> </table> </div> </div> <p> <br> <input type="submit" name="submit1"> <input type="reset" name="reset1"> </p> <p id="addnew"></p> <FORM> <INPUT type="button" value="Add New" name="button2" onClick="javascript:new_link()"> </FORM> </form> <!-- Template --> <div id="newlinktpl" style="display:none"> <div> <table border=0> <TR><TD><B>Product:</B> </TD><TD><input type=text name=<?$_POST[++$i];?> value="<?$_GET[$i];?>"> </TD> <TD><B>Price:</B> </TD><TD><input type=text name=<?$_POST [++$i];?> value="<?$_GET[$i].$curency;?>"> </TD></TR> </form> </TABLE> <?include("footer.php");?> in the code above i tryed to make the programm POST the numbers in the name increcing it by 1. But when i click submit i get offset error. The processing file : <? $timestamp = strftime("%d-%m-%Y %H:%M:%S %Y"); // for later use (ignore it) $i =1; #################################################################################### if(($_POST['prodname']!="")&&($_POST['price']!="")){ ############################################################ $writetocsv = $_POST['prodname1'] . "," . $_POST['price1']"%" <BR> . $_POST[$i] . $_POST[$i]; $fp = fopen("data/data.csv", "a"); fwrite ($fp,$writetocsv); fclose ($fp); echo "<script>alert('Data sent.')</script>"; } else{ echo "<script>alert('Error! Please fill the form!')</script>"; } echo "<script>location.replace('index.php')</script>"; ?> Perhaps someone knows a easyer way , since i am not sure how to make stuff due to the lack of knowlage in php. I also tryed arrays but , as said before , too tough when you are a noob Please help. |