PHP - Url Parameter Values Not Being Received When Using Rawurlencode
I am using rawurlencode for my urls, like this:
Similar Tutorials
Table Issue - Multiple Location Values For User Pushes Values Out Of Row Instead Of Wrapping In Cell
GREAT this forum - JUST GREAT !... Issue: All data entered into my online form was lost (blanked out) and the form returned correctly with message "wrong verification code", when submitted with the wrong verification code. However, going through this great forum I managed to get all - manually entered - data back ! I placed value="<?php echo $_GET['the_field_name'];?>"/ after each input field. BUT... not so with input fields entered from drop-down menu ! How do I put a similar string for the field "Payment by" in this sample: <tr> <td class="table-inquire" width="47%"> <font face="Verdana" size="1" color="#000042"> Payment by:</font></td> <td class="table-inquire" width="51%" colspan="2"> <font color="#400000" face="Verdana"> <select name="payment" size="1"> <option value="VISA">VISA</option> <option value="MASTER">MASTER</option> <option value="CASH">CASH</option> <option value="T/T Banktransfer">T/T Banktransfer</option> <option selected>Please select</option> </select></font><font size="2" color="#400000" face="Verdana"></font></td> </tr> Any advise greatly appreciated. Thanks. Hi all I am building a page to filter SQL values but I'm not sure how to write the code for the query. My URL looks like this: stone.php?category=Wood&type=4&colour=1&Submit=Submit Firstly, can I remove the submit from the URL? Then I have my code to create the query: $fetchData=mysql_query("SELECT * FROM `products` WHERE category = "'.$_GET'category.'""); Can I combine this for the type and colour? Many thanks Pete Hey people just been watching a php tutorial that mentions using rawurlencode for the links, ive pretty much followed th tutorial to the later bar using different pages, see coding below. However, it just doesnt work bringing back that object was not found Any ideas whats going wrong or why it isn't working? Code: [Select] <?php #retrive from database and do a foreach loop maybe. $urlPage = "loginArea/login.php"; $param1 = "robert"; $url = "http://localhost/duff3/"; $url .= rawurlencode($urlPage); $url .= "?userId=" . urlencode($param1); ?> <ul class="menu"> <li><a href="<?php $_SERVER["DOCUMENT_ROOT"] ?>/duff3/index.php" class="nav_selected"> home </a></li> <li><a href="test.php?id=1" class="nav"> bio</a></li> <li><a href="<?php echo htmlspecialchars($url); ?>" class="nav"> publicity</a></li> <li><a href="" class="nav"> recordings</a></li> <li><a href="" class="nav"> contact </a></li> </ul> I have the following code just to insert a username and hashed password into the database but somehow I am getting this error and I couldn't find out where I am doing it wrong...can someone please give me a hand?
I tried it in two ways and both errors...
the first few lines are just connecting database which worked fine and a password.php so I can use password_hash() with my php version
$hash = password_hash('xx', PASSWORD_BCRYPT, array('cost' => 10)); $username = 'xx'; $insertQuery = $db->prepare(" INSERT INTO et_todo (username, password) VALUES (:username, :hash) "); $insertQuery->execute(array( 'username' => $username, 'password' => $hash ));also tried $hash = password_hash('xx', PASSWORD_BCRYPT, array('cost' => 10)); $insertQuery = $db->prepare(" INSERT INTO et_todo (username, password) VALUES ('xx', :hash) "); $insertQuery->execute(array( 'username' => 'xx', 'password' => $hash )); Hello,
I recently posted here about an issue I was having with my database orientated products page.
I have now run into another problem where say if, /db.php was typed or /db.php?p=IDoNotExist was typed, it returns blank.
I have in my code the desired content to be displayed, but it just doesn't seem to want to make a show.
I was also wondering if it is possible to show different content for whatever the URL is, so for no parameter, the content about the products, and a non existent one, maybe "Product not found"?
Here is my code:
<?php $db=mysql_connect ("localhost", "webwibco_charlie", "Hello123") or die ('I cannot connect to the database because: ' . mysql_error()); $mydb=mysql_select_db("webwibco_products"); include("header.php"); $status = htmlspecialchars( @$_GET ['p'] ); if ($status == "floorpuzzles") { echo "<h1>Our Floor Puzzles</h1>"; $sql="SELECT ID, Name, Tags, Description, Category FROM products WHERE Category LIKE '%" . FloorPuzzles . "%'"; $result=mysql_query($sql); while($row=mysql_fetch_array($result)){ $Name =$row['Name']; $ID =$row['ID']; $Description =$row['Description']; echo "<div class=\"box\">"; echo "<h1>$Name</h1>"; echo "<div class=\"floorbox\"><a href=\"?p=$ID\"><img src=\"images/products/catalogue/big/floorpuzzles/$ID.jpg\" class=\"small\"></a></div>"; echo "<h2>$Description</h2>"; echo "</div>"; } ?> <? }else{ if ($status == $_GET["p"]) { $sql="SELECT ID, Name, Tags, Description, Pieces, Size, Barcode, Category FROM products WHERE ID = '" . $_GET['p'] . "'"; $result=mysql_query($sql); while($row=mysql_fetch_array($result)){ $Name =$row['Name']; $ID =$row['ID']; $Description =$row['Description']; $Pieces =$row['Pieces']; $Size =$row['Size']; $Barcode =$row['Barcode']; echo "<div class=\"1\">"; echo "<h1>$Name</h1>"; echo "<div class=\"bigbox\">"; echo "<div class=\"floorbox\"><img src=\"images/products/catalogue/big/floorpuzzles/$ID.jpg\" class=\"big\"></div>"; echo "</div>"; echo "</div>"; echo "<div class=\"2\">"; echo "<p>Puzzle Pieces: $Pieces</p> <p>Puzzle Size: $Size</p> <p>Barcode: $Barcode</p>"; echo "</div>"; } }else{ ?> <? echo"<h1>Our Products</h1> <p>Our jigsaw puzzles are hand cut by skilled craftsmen and therefore each one is unique with self-correcting pieces. There is a strict quality control process at all stages by our highly experienced staff. The puzzles are durable and provide fun and excitement, enhancing learning and a child’s development.<p> <p>All of our jigsaws are made using materials from sustainable resources grown in managed forests. Where possible we support companies in the UK and source our components locally, most of our suppliers are in the East Midlands, many in Derbyshire and Nottinghamshire. We keep packaging to a minimum and take our environmental and ethical responsibilities very seriously.</p> <p>Reducing waste and recycling was a way of life for us before it became fashionable. We are constantly searching for new ideas and consult teachers when developing our jigsaws, which are often used within the national curriculum.</p> <p>As well as making our own range, we manufacture for leading suppliers to the education market. Check for \"Made in Britain\" and it is probably made by us.</p> <p>We have a wide variety of products available for viewing, from classic floor puzzles to innovative inset trays. You can take a look at all our products on this page, simply use the navigation buttons to your left.</p>"; }} include("footer.php"); ?>The final echo is what I wish to be displayed on the URL without or with an invalid parameter. Here is my site URL: http://www.webwib.co...saws/search.php (note that only the "Floor Puzzles" category has content within it). Thank you in advance for assistance. Hi guys ,
I am facing issues with php mails. I have iis and SMTP configured on the sever . Mail send and receive was working properly. But suddenly not able to receive email. I have tried simple php email script . it shows email sent but not received. I have tried php mailer also but same happened. Please reply if somebody could help me out. i need to resolve this issue as soon as possible. I have iis 6 and windows 2012 and php 5.5
Edited by Poonam, 21 August 2014 - 08:36 AM. Hello once again Php Freaks! I've probably posted this problem a few times a year for the past 5 or so years. I am a dev/admin for the site marcomtechnologies.com. From that website, using php we send emails out. Some users never get the email and it isn't in their spam folder. The two users we can confirm never get the email have @att.net email address and, let me warn you. Do not ever, EVER call att/yahoo/sbc for tech support. It's an endless circle and when you do finally talk to someone, they have a really hard time grasping that it is about emails coming from a server they are not hosting.
I've talked to GoDaddy everytime, and everytime it is the same thing. Everything is ok on their end.
I will post the code below. First what I have done.
- The emails are coming "FROM" the correct domain. The website is marcomtechnologies.com, and the emails are from admin@marcomtechnologies.com. This was something that if not set this way, would be flagged as spam right off the top. this is a valid email, on the email services provided by godaddy. I can log in and send and receive emails from there no problem.
- I was using the standard PHP mail command, than switched to PHPMailer and we still have the same problem.
- I have checked to see if the domain is blacklisted. As far as I can tell it is not. If it was true, than my address, @gmail wouldn't get the emails and I do. (quick note, a few weeks ago even I didn't get some?)
- GoDaddy tells me that we have 250 "relays" or emails that can go out. On a daily basis, we may send 50 messages. If that.
- I have tried to get bounce back messages stating the message was undelivered and have yet to ever get one.
- We have set up read receipts and they work, but not every sales person reads their emails, just kinda ignores them. So read receipts are not really helping us, cause we don't know if they are ignoring the message, or not getting them.
- For one of our customers, we had to talk to an admin and have them put a rule on there server allowing messages from our domain. From what we can tell it worked, but again are the sales staff ignoring, or not getting the message? We don't know until we are there and they say so. Why is att.net not getting them?
The emails are going out and leaving godaddy. Somewhere between godaddy and the receiver, the message is blocked, lost, deleted or just decides to take a day off. Which is really what seems to be happening. I've reach a state of utter frustration with this. Emails are a simple, all over the place, everyone uses, and has for a long long time technology. What can I do to confirm they got the message without them having to actually read it? What can I do to determine why the message isn't making it? I'm never getting those bounce backs, so I have no details at all.
The clients we serve are not the most tech capable, and for all we know everything is ok. the problem is, for my boss, this is unacceptable. I need a solution, and a confirmation that the solution is working 110%.
What am I missing? Here is the chuck of code that sends the messages out :
require 'PHPMailer/PHPMailerAutoload.php'; require_once('PHPMailer/class.phpmailer.php'); $results_messages = array(); $mail = new PHPMailer(true); $mail->CharSet = 'utf-8'; class phpmailerAppException extends phpmailerException {} if($file_name[0]=='') { try { if(!PHPMailer::validateAddress($to)) { throw new phpmailerAppException("Email address " . $to . " is invalid -- aborting!"); } $body = $email_message; $body = eregi_replace("[\]",'',$body); $mail->AddReplyTo($_SESSION['member_email'],$_SESSION['WholeName']); $mail->SetFrom("admin@marcomtechnologies.com",$_SESSION['WholeName']); $mail->AddAddress($to,$to); $mail->Subject = $MSG_row['msg_subject']; $mail->MsgHTML($body); if(!$mail->Send()) { $results_messages[] = "Mailer Error: " . $mail->ErrorInfo; } else { $results_messages[] = "Message has been sent to " . $to . ', '; } } catch (phpmailerAppException $e) { $results_messages[] = $e->errorMessage(); } } else { $path = '../audio_upload/' . $audio_filename; $path_name=$audio_filename; try { if(!PHPMailer::validateAddress($to)) { throw new phpmailerAppException("Email address " . $to . " is invalid -- aborting!"); } $mail->isSendmail(); $mail->addReplyTo($_SESSION['member_email'], $_SESSION['WholeName']); $mail->SetFrom("admin@marcomtechnologies.com",$_SESSION['WholeName']); $mail->addAddress($to, $to); $mail->Subject = $MSG_row['msg_subject']; //$body = "<<<'EOT'"; $body = $email_message; //$body .= "EOT"; $mail->WordWrap = 80; $mail->msgHTML($body, dirname(__FILE__), true); //Create message bodies and embed images // preparing attachments $main_path='email_upload/'; for($x=0;$x<count($file_name);$x++){ $mail->addAttachment($main_path.$file_name[$x]); // optional name } try { $mail->send(); $results_messages[] = "Message has been sent to " . $to . ', '; } catch (phpmailerException $e) { throw new phpmailerAppException('Unable to send to: ' . $to. ': '.$e->getMessage()); } } catch (phpmailerAppException $e) { $results_messages[] = $e->errorMessage(); } } $mail->clearAddresses(); $mail->clearAttachments();The above is just the part that sends the email, it is part of an AJAX file, and you can download a ZIP with the whole file he http://marcomtechnol.../email_code.zip I have removed the database usernames/password stuff. You will see what I mean, other than that it is 100% complete. I have absolutely no idea what to do. I'm in the dark blindfolded. Thank you so much for taking the time to review my problem! Nick I have a site that allows people to register for a fee. It is a very basic form asking for name and contact info.
After they fill out the form and submit it, they are brought to paypal to make their payment. After paying, the form data is sent to the admin and to the customer.
What is very strange is the form seems to work perfectly most of the time, except sometimes:
1. the email is not received by the admin (not sure if the buyer is getting their copy though).
2. if multiple email addresses in the admin settings to receive it (comma separated), sometimes some receive it, but some do not!
The owner of the site said they do check their spam and we've tried different email addresses for the admin (gmail, outlook, yahoo, etc..) and it has occurred on all of them, no rhyme or reason.
Do you see anything wrong with my form below that would have this intermittent issue?
Also, anyone suggest how I can add headers to this so that the 'from' won't default to the host server name?
The file admin.php contains the email variable $admin_email
<?php require '../admin.php'; session_start(); if (!isset($_SESSION['order_id']) || empty($_SESSION['order_id'])) { header('Location: ../../'); } // admin email mail($admin_email, 'Website form submitted', 'Visitor information. Registration: ' . $_SESSION['order_id']."\r\n".' First Name: ' .$_SESSION['fname'].' Last Name: ' .$_SESSION['lname'].' Email: ' .$_SESSION['email'].' Phone: ' .$_SESSION['phone']); // visitor email $to = $_SESSION['email']; mail($to, 'Thank you for registering', 'Review your submission below. Please contact us if you need further assistance. Registration: ' . $_SESSION['order_id']."\r\n".' First Name: ' .$_SESSION['fname'].' Last Name: ' .$_SESSION['lname'].' Email: ' .$_SESSION['email'].' Phone: ' .$_SESSION['phone']); session_destroy(); ?> Hi all, I have made some code based on following online youtube video for making a HTML form send to mySQL database via PHP: https://youtu.be/qm4Eih_2p-M The form I am making is hopefully going to help in the Hospital at which I work to speed patient referrals, so I am very keen on making it work. I have made the HTML form and the database, which I do not think are the problem. When I click 'Submit' on my HTML form, then my php file comes up with all the code written, rather than the message: "New referral sent succesfully". Additionally, when I check the database via 'MyPHPAdmin' there is no data added to the database I have made.
I have been using Sublime and have spotted some mistakes here and there, but is there something glaringly obvious that I am doing wrong in my code that is stopping my form being sent to the database? <?php $patientname = | $_POST['patientname']; $hospitalnumber = | $_POST['hospitalnumber']; $DoB = | $_POST['DoB']; $specialty = | $_POST['specialty']; $otherspecialty = | $_POST['otherspecialty']; $admissiondate = | $_POST['admissiondate']; $referring = | $_POST['referring']; $bleep = | $_POST['bleep']; $Admission = | $_POST['Admission']; $Illness = | $_POST['Illness']; $Awareness = | $_POST['Awareness']; $question = | $_POST['question']; $history = | $_POST['history']; $medications = | $_POST['medications']; $examination = | $_POST['examination']; $results = | $_POST['results']; $diagnosis = | $_POST['diagnosis']; $investigations = | $_POST['investigations']; $host = "localhost" $dbUsername = "root"; $dbPassword = "xyzabc"; $dbname = "GreenCard"; $conn = new mysqli($host, $dbUsername, $dbPassword, $dbname); if (mysqli_connect_error()) { die('Connect Error('. mysqli_connect_errno().')'. mysqli_connect_error()); } else { $INSERT = "INSERT Into Greencard (patientname, hospitalnumber, DoB, specialty, otherspecialty, admissiondate, referring, bleep, Admission, Illness, Awareness, question, history, medications, examination, results, diagnosis, investigations) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"; //Prepare statement $stmt = $conn->prepare($INSERT); $stmt->bind_param("sisissssssssssssss", $patientname, $hospitalnumber, $DoB, $specialty, $otherspecialty, $admissiondate, $referring, $bleep, $Admission, $Illness, $Awareness, $question, $history, $medications, $examination, $results, $diagnosis, $investigations); $stmt->execute(); echo "New referral sent successfully"; } $stmt->close(); $conn->close(); } else { echo "Make sure fields are completed"; die(); } ?>
Hello all, I am having a bit of trouble with this contact form. Everything submits fine, errors work and all but the information isn't sent to my inbox. Can anyone point out where the problem is? Thanks in advance! Code: [Select] if(isset($_POST['Email_Address'])) { include 'free_settings.php'; function died($error) { echo "Sorry, but there were error(s) found with the form you submitted. "; echo "These errors appear below.<br /><br />"; echo $error."<br /><br />"; echo "Please go back and fix these errors.<br /><br />"; die(); } if(!isset($_POST['Full_Name']) || !isset($_POST['Email_Address']) || !isset($_POST['Your_Message'])) { died('We are sorry, but there appears to be a problem with the form you submitted.'); } $full_name = $_POST['Full_Name']; // required $email_from = $_POST['Email_Address']; // required $comments = $_POST['Your_Message']; // required $error_message = ""; $email_exp = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/'; if(preg_match($email_exp,$email_from)==0) { $error_message .= 'The Email Address you entered does not appear to be valid.<br />'; } if(strlen($full_name) < 2) { $error_message .= 'Your Name does not appear to be valid.<br />'; } if(strlen($comments) < 2) { $error_message .= 'The Comments you entered do not appear to be valid.<br />'; } if(strlen($error_message) > 0) { died($error_message); } $email_message = "Form details below.\r\n"; function clean_string($string) { $bad = array("content-type","bcc:","to:","cc:","href"); return str_replace($bad,"",$string); } $email_message .= "Full Name: ".clean_string($full_name)."\r\n"; $email_message .= "Email: ".clean_string($email_from)."\r\n"; $email_message .= "Message: ".clean_string($comments)."\r\n"; $headers = 'From: '.$email_from."\r\n". 'Reply-To: '.$email_from."\r\n" . 'X-Mailer: PHP/' . phpversion(); @mail($email_to, $email_subject, $email_message, $headers); header("Location: $thankyou"); ?> <script>location.replace('<?php echo $thankyou;?>')</script> <?php Hi, I am using PHP mail() function to sent message. Following is the code, the message is received in email account, but as attachment, not displayed in the body section as normal message would. Please can you guys help, as why is this message going as attachment, but not being displayed in the body of email. Below is the url which gives preview as to what I mean. http://i56.tinypic.com/29fujxf.jpg Code: [Select] $to = $_POST['to']; $subject = ' web visior'; $customer = stripslashes($_POST['customer']); $email = stripslashes($_POST['email']); $contactinfo = stripslashes($_POST['contactinfo']); $body = stripslashes($_POST['enquiry']); $header = 'From:'.$email.'\r\n'; $header = 'Reply-To:'.$email.'\r\n'; $header = 'X-Mailer: PHP/' . phpversion(); $header = 'Content-type: text/html\r\n'; $message = '<html><body> <table> <tr><td>From:'.$customer.'</td></tr> <tr><td>Email:'.$email.'</td></tr> <tr><td>Contact No'.$contactinfo.'</td></tr> <tr><td style="center"><b>Message:</b></td></tr> <tr><td>'.$body.'</td></tr> </body></html>'; Regards, Abhishek Hi All, Is there a way we can write a PHP script to automatically read receive emails, extract csv file attachment from there and insert into MySQL database then run this in Cron Jobs to automate the process? I really need some help. I am very new to PHP and I've been stuck for a couple of days. I created a contact form and everything seems to be working correctly, except the mail is showing it's sent, but I never receive an email in my Inbox or Spam folder. Can someone please review my code? Here is the PHP: <?php // DEFINE VARIABLE AND SET EMPTY VALUES $varfnameErr = $varlnameErr = $varemailErr = $varphoneErr = $varpositionErr = ""; $varfname = $varlname = $varemail = $varphone = $varposition = $success = ""; //FORM SUBMITTED WITH POST METHOD if ($_SERVER["REQUEST_METHOD"] == "POST") { //VALIDATE FIRST NAME if (empty($_POST["varfname"])) { $varfnameErr = "First Name is required"; } else { $varfname = test_input($_POST["varfname"]); // MAKE SURE FIRST NAME ONLY CONTAINS LETTERS AND WHITE SPACE if (!preg_match("/^[a-zA-Z ]*$/",$varfname)) { $varfnameErr = "Only letters and white space are allowed"; } } //VALIDATE LAST NAME if (empty($_POST["varlname"])) { $varlnameErr = "Last Name is required"; } else { $varlname = test_input($_POST["varlname"]); // MAKE SURE LAST NAME ONLY CONTAINS LETTERS AND WHITE SPACE if (!preg_match("/^[a-zA-Z ]*$/",$varlname)) { $varlnameErr = "Only letters and white space are allowed"; } } //VALIDATE EMAIL ADDRESS if (empty($_POST["varemail"])) { $varemailErr = "Email Address is required"; } else { $varemail = test_input($_POST["varemail"]); // MAKE SURE EMAIL ADDRESS IS FORMATTED CORRECTLY if (!filter_var($varemail, FILTER_VALIDATE_EMAIL)) { $varemailErr = "Invalid email address format"; } } //VALIDATE PHONE NUMBER if (empty($_POST["varphone"])) { $varphoneErr = "Phone number is required"; } else { $varphone = test_input($_POST["varphone"]); // MAKE SURE PHONE NUMBER IS IN CORRECT FORMAT if (!preg_match("/^(\d[\s-]?)?[\(\[\s-]{0,2}?\d{3}[\)\]\s-]{0,2}?\d{3}[\s-]?\d{4}$/i",$varphone)) { $varphoneErr = "Invalid telephone format"; } } //VALIDATE POSITION if (empty($_POST["varposition"])) { $varpositionErr = "Position is required"; } else { $varposition = test_input($_POST["varposition"]); } //IF ALL DATA IS CORRECT if ($varfnameErr == '' and $varlnameErr == '' and $varemailErr == '' and $varphoneErr == '' and $varpositionErr == '') { $message_body = ''; unset($_POST['submit']); //THIS IS JUST FOR TESTING PURPOSES $message_body = $varfname; //foreach ($_POST as $key => $value) { // $message_body .= "$key: $value\n"; //} $to = 'mygmail@gmail.com'; $subject = 'Volunteer Form Submission'; $message = wordwrap($message_body, 70); $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=utf-8' . "\r\n"; $headers .= "From: " . $varemail . "\r\n"; $subject = 'Volunteer Form Submission'; $to = 'mygmail@gmail.com'; $result = mail($to, $subject, $message, $headers); //THIS RETURNS "1" print $result; //IF ALL DATA IS CORRECT MAKE SURE EMAIL WAS SENT if (mail($to, $subject, $message, $headers)) { $success = "Message sent. Thank you contacting us! We will reply as soon as possible."; $varfname = $varlname = $varemail = $varphone = $varposition = ""; } else { $success = "Something went wrong!"; } } } //STRIP UNWANTED CHARACTERS FROM VARIABLES function test_input($data) { $data = trim($data); $data = stripslashes($data); $data = htmlspecialchars($data); return $data; } ?>
Here is the HTML: <div class="row regformrow"> <div class="coffee-span-12 regformcolumn"> <div class="subgrid regformsubgrid"> <div class="row regformsubgridheaderrow"> <div class="coffee-span-12 regformsubgridheadercolumn"> <h4 class="regformsubgridheadertitle">Volunteer Form</h4> </div> </div> <div class="row regformsubgridrow"> <form class="form-container regformsubgridformcontainer" action=<?= $_SERVER['PHP_SELF']; ?> method="post"> <div class="coffee-span-4 coffee-972-span-6 coffee-458-span-12 regformsubgridcolumn1"> <div class="container regformsubgridcontainer1"> <label class="label form-label-all"><span style="font-style:italic;color:#FF5454;">* Required Fields</span></label></br> <div class="formfieldgroup"> <input class="fname" name="varfname" type="text" tabindex="1" placeholder="First Name" value="<?= $varfname; ?>"><span class="requiredfield"> *</span> <span class="form-error"><?= $varfnameErr ?></span> </div> <div class="formfieldgroup"> <input class="lname" name="varlname" type="text" tabindex="2" placeholder="Last Name" value="<?= $varlname; ?>"><span class="requiredfield"> *</span> <span class="form-error"><?= $varlnameErr ?></span> </div> <div class="formfieldgroup"> <input class="email" name="varemail" type="text" tabindex="2" placeholder="Email Address" value="<?= $varemail; ?>"><span class="requiredfield"> *</span> <span class="form-error"><?= $varemailErr ?></span> </div> <div class="formfieldgroup"> <input class="phone" name="varphone" type="text" tabindex="2" placeholder="Telephone Number" value="<?= $varphone; ?>"><span class="requiredfield"> *</span> <span class="form-error"><?= $varphoneErr ?></span> </div> <div class="formfieldgroup"> <select class="select selectbox" name="varposition" id="varposition" tabindex="5"><option value="">Select one...</option><option value="Chaperone">Chaperone</option><option value="Class Monitor">Class Monitor</option><option value="Parking Attendant">Parking Attendant</option><option value="Party Coordinator">Party Coordinator</option><option value="Teacher Aid">Teacher Aid</option></select><span class="requiredfield"> *</span> <span class="form-error"><?= $varpositionErr ?></span> </div> <div class="formfieldgroup"> <input class="test" name="test" type="text" tabindex="6" placeholder="If you are human, leave this field blank" value=""> </div> <div class="formfieldgroup"> <button type="submit" class="button-submit-1" name="submit" tabindex="7" data-submit="...Sendng">Submit</button> </div> <div class="formfieldgroup"> <div class="success"><?= $success; ?></div> </div> </div> </div> </form> </div> </div> </div> </div> Edited February 20, 2020 by mike3075 Hi All, Is there a way we can write a PHP script to automatically read receive emails, extract csv file attachment from there and insert into MySQL database then run this in Cron Jobs to automate the process? Hi guys, I'm trying to write a script that generates a multipart plaintext/HTML email with a pdf attachment. After much research and trial & error, I seem to have reached a wall. At the moment, I am testing in gmail, hotmail and Outlook 2003. Gmail displays the HTML alternative of the message and attaches the pdf document, while hotmail & Outlook only attach the pdf without displaying either of the message alternatives. Here is the code: // Error display ini_set ('display_errors', 1); error_reporting (E_ALL | E_STRICT); // Setting a timestamp date_default_timezone_set('Australia/Perth'); $timestamp = date("d/m/y H:i:s", time()); // Create a boundary string. It must be unique, so we use the MD5 algorithm to generate a random hash $random_hash = md5(time()); // Read the attachment file contents into a string, encode it with MIME base64 & split it into smaller chunks $attachment = chunk_split(base64_encode(file_get_contents("success.pdf"))); // Create the Plain text message to be sent in the email body $content_text = "Hello, World!! \nIs this a Plain Text alternative?"; // Create the HTML message to be sent in the email body $content_html = "<html><body><h1>Hello, World!!</h1><p>This is <b>HTML</b> formatting.</p></body></html>"; // Sending the email $to = "$email"; $subject = "Test5-3.php :: $timestamp"; $headers = "From: The Company <webmaster@example.com>\n"; $headers .= "MIME-Version: 1.0\n"; $headers .= "Content-Type: multipart/mixed; boundary=\"$random_hash\"\n"; $headers .= "--$random_hash\n"; $headers .= "Content-Type: application/pdf\n"; $headers .= "Content-Transfer-Encoding: base64\n"; $headers .= "Content-Disposition: attachment; filename=\"success.pdf\"\n\n"; $headers .= "$attachment\n"; $message = "Content-Type: multipart/alternative; boundary=\"$random_hash\"\n"; $message .= "Content-Type: text/plain; charset=\"iso-8859-1\"\n"; $message .= "Content-Transfer-Encoding: 7bit\n"; $message .= "$content_text\n"; $message .= "--$random_hash\n"; $message .= "Content-Type: text/html; charset=\"iso-8859-1\"\n"; $message .= "Content-Transfer-Encoding: 7bit\n"; $message .= "$content_html\n"; $message .= "--$random_hash--"; // Send the data in an email $mail_sent = @mail ($to, $subject, $message, $headers, "[email]-froot@clarebyrnedesign.com.au[/email]"); (That's not the full script, but it is the relevant part of it. The full script is attached.) Other variations of this code I have tried out include: - surrounding all the variables with ". .", eg: $headers .= "--".$random_hash."\n"; - sending the entire function as headers, instead of splitting it into message and headers, eg: $headers = "From: The Company <webmaster@example.com>\n"; $headers .= "MIME-Version: 1.0\n"; $headers .= "Content-Type: multipart/mixed; boundary=\"$random_hash\"\n"; $headers .= "--$random_hash\n"; $headers .= "Content-Type: application/pdf\n"; $headers .= "Content-Transfer-Encoding: base64\n"; $headers .= "Content-Disposition: attachment; filename=\"success.pdf\"\n\n"; $headers .= "$attachment\n"; $headers .= "Content-Type: multipart/alternative; boundary=\"$random_hash\"\n"; $headers .= "Content-Type: text/plain; charset=\"iso-8859-1\"\n"; $headers .= "Content-Transfer-Encoding: 7bit\n"; $headers .= "$content_text\n"; $headers .= "--$random_hash\n"; $headers .= "Content-Type: text/html; charset=\"iso-8859-1\"\n"; $headers .= "Content-Transfer-Encoding: 7bit\n"; $headers .= "$content_html\n"; $headers .= "--$random_hash--"; Does anyone know why I would be having this problem? It seems that nothing I've tried will work!! Thanks Hi, i have tried everything i can think of to get this to work correctly. What is below here, is what i have last tried to work with..: basically the script allows the use to register an email account on a cpanel domain. Everything works perfectly but then i added a option for banned words now i cant get the script to work.. basically what happens is: the user creates an email account, if the account is not a banned word and does not exist, then the message echoes success, and the $_Post values are also entered into the database under the users name. and the email is also created with the $f fopen if success the email form also does not show.. so only one email per user.. i just cant get it to work with the banned words included.. what to note:: this is a function in a function.. $bannedemailwords='customerinformation,custinfo,customerinfo,custtext,custsupport,customersupport,admin,accounts'; $bannedmail=explode(',', $bannedemailwords); $bannedmail = array_unique($bannedmail); sort($bannedmail); foreach($bannedmail as $noemail) //the selected username if ($Config['enablemyemailapp_enable'] == '0' && $_POST['cfg_enablemyemailappaddress_enable'] !== $noemaill && $_POST['cfg_enablemyemailappaddressdomain_enable'] !== 'Select a domain'){ $cpuser = 'ausername'; $cppass = 'apassword'; $cpdomain = 'adomain'; $cpskin = 'askin'; $epass = 'somepassword'; $equota = 'somequota'; $euser = $_POST['cfg_enablemyemailappaddress_enable']; $epass = $_POST['emailspassword_enable']; $edomain = $_POST['cfg_enablemyemailappaddressdomain_enable']; if (!empty($euser) && $euser !=='nomail') while(true) { $f = fopen ("http://$cpuser:$cppass@$cpdomain:2082/frontend/$cpskin/mail/doaddpop.html?email=$euser&domain=$edomain&password=$epass"a=$equota", "r"); if (!$f) { $enablemyemailapp_enable = '0'; $enablemyemailappaddress_enable = 'Replace with a Name'; $enablemyemailappaddressdomain_enable = 'Select a domain'; $msgemail = 'The email '.$euser.'@'.$edomain.' is a restricted email account.'; break; } $enablemyemailapp_enable = '1'; $enablemyemailappaddress_enable = $_POST['cfg_enablemyemailappaddress_enable']; $enablemyemailappaddressdomain_enable = $_POST['cfg_enablemyemailappaddressdomain_enable']; $msgemail ='<center><font color="#ff0033">Your Email '.$euser.'@'.$edomain.' has been created.</font></center>'; while (!feof ($f)) { $line = fgets ($f, 1024); if (ereg ("already exists", $line, $out)) { $enablemyemailapp_enable = '0'; $enablemyemailappaddress_enable = 'Replace with a Name'; $enablemyemailappaddressdomain_enable = 'Select a domain'; $msgemail ='<center><font color="#ff0033">The email account '.$euser.'@'.$edomain.' already exists.</font></center><br><center>Please try again!</center>'; break; } } echo $msgemail; $_POST['cfg_enablemyemailapp_enable']= $enablemyemailapp_enable; $_POST['cfg_enablemyemailappaddress_enable']=$enablemyemailappaddress_enable; $_POST['cfg_enablemyemailappaddressdomain_enable']=$enablemyemailappaddressdomain_enable; @fclose($f); break; } } I have been trying to get my files to upload onto a computer and I receive this message: Parse error: syntax error, unexpected T_STRING in /home/content/19/6550319/html/listing.php on line 27. Line 27 is how the php logs into my SQL. The problem is that I was able to log in before. I just made changes to the form by adding a dropdown menu and price and now it says it doesnt parse. Can anyone figure this out. I will include the code without the login information because the forum is public but I did put the words left out for you to see where I took out the passcodes. Code: [Select] <?php //This is the directory where images will be saved $target = "potofiles/"; $target = $target . basename( $_FILES['photo']['name']); //This gets all the other information from the form $price=$_POST['price']; $gig=$_POST['giga']; $yesg=$_POST['yesg']; $pic=($_FILES['photo']['name']); $pic2=($_FILES['phototwo']['name']); $pic3=($_FILES['photothree']['name']); $pic4=($_FILES['photofour']['name']); $description=$_POST['iPadDescription']; $condition=$_POST['condition']; $fname=$_POST['firstName']; $lname=$_POST['lastName']; $email=$_POST['email'] // Connects to your Database mysql_connect ("left out", "left out", "left out") or die(mysql_error()) ; mysql_select_db("left out") or die(mysql_error()) ; //Writes the information to the database mysql_query("INSERT INTO listing (price,giga,yesg,photo,phototwo,photothree,photofour,iPadDescription,condition,firstName,lastName,email) VALUES ('$price', '$gig', '$yesg', '$pic', '$pic2', '$pic3', '$pic4', '$description', '$condition', '$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()) ?> Hello, recently I changed host of my website and when a visitor clicks "contact us" button in my website (in which one needs to enter his/ her email, name, phone , etc) and submit his/her message then I get email. Before this hosting I used to get emails from the visitor who filled the form so it was easier for me to reply but now after I changed the host I get email as "mydomain@hosting-company-domain" instead of the visitor's email. I messaged them then they told me something about SMTP authenticate using PHP, please guide me to fix this. Dear All Members here is my table data.. (4 Columns/1row in mysql table)
id order_no order_date miles How to split(miles) single column into (state, miles) two columns and output like following 5 columns /4rows in mysql using php code.
(5 Columns in mysql table) id order_no order_date state miles 310 001 02-15-2020 MI 108.53 310 001 02-15-2020 Oh 194.57 310 001 02-15-2020 PA 182.22
310 001 02-15-2020 WA 238.57 ------------------my php code -----------
<?php
if(isset($_POST["add"]))
$miles = explode("\r\n", $_POST["miles"]);
$query = $dbh->prepare($sql);
$lastInsertId = $dbh->lastInsertId(); if($query->execute()) {
$sql = "update tis_invoice set flag='1' where order_no=:order_no"; $query->execute();
} ----------------- my form code ------------------
<?php -- Can any one help how to correct my code..present nothing inserted on table
Thank You Edited February 8, 2020 by karthicbabuHi, My company has 240+ locations and as such some users (general managers) cover multiple sites. When I run a query to pull user information, when the user has multiple sites to his or her name, its adds the second / third sites to the next columns, rather than wrapping it inside the same table cell. It also works the opposite way, if a piece of data is missing in the database and is blank, its pull the following columns in. Both cases mess up the table and formatting. I'm extremely new to any kind of programming and maybe this isn't the forum for this question but figured I'd give it a chance since I'm stuck. The HTML/PHP code is below: <table id="datatables-column-search-select-inputs" class="table table-striped" style="width:100%"> <thead> <tr> <th>ID</th> <th>FirstName</th> <th>LastName</th> <th>Username</th> <th>Phone #</th> <th>Location</th> <th>Title</th> <th>Role</th> <th>Actions</th> </tr> </thead> <tbody> <?php //QUERY TO SELECT ALL USERS FROM DATABASE $query = "SELECT * FROM users"; $select_users = mysqli_query($connection,$query);
// SET VARIABLE TO ARRAY FROM QUERY while($row = mysqli_fetch_assoc($select_users)) { $user_id = $row['user_id']; $user_firstname = $row['user_firstname']; $user_lastname = $row['user_lastname']; $username = $row['username']; $user_phone = $row['user_phone']; $user_image = $row['user_image']; $user_title_id = $row['user_title_id']; $user_role_id = $row['user_role_id'];
// POPULATES DATA INTO THE TABLE echo "<tr>"; echo "<td>{$user_id}</td>"; echo "<td>{$user_firstname}</td>"; echo "<td>{$user_lastname}</td>"; echo "<td>{$username}</td>"; echo "<td>{$user_phone}</td>";
//PULL SITE STATUS BASED ON SITE STATUS ID $query = "SELECT * FROM sites WHERE site_manager_id = {$user_id} "; $select_site = mysqli_query($connection, $query); while($row = mysqli_fetch_assoc($select_site)) { $site_name = $row['site_name']; echo "<td>{$site_name}</td>"; } echo "<td>{$user_title_id}</td>"; echo "<td>{$user_role_id}</td>"; echo "<td class='table-action'> <a href='#'><i class='align-middle' data-feather='edit-2'></i></a> <a href='#'><i class='align-middle' data-feather='trash'></i></a> </td>"; //echo "<td><a href='users.php?source=edit_user&p_id={$user_id}'>Edit</a></td>"; echo "</tr>"; } ?>
<tr> <td>ID</td> <td>FirstName</td> <td>LastName</td> <td>Username</td> <td>Phone #</td> <td>Location</td> <td>Title</td> <td>Role</td> <td class="table-action"> <a href="#"><i class="align-middle" data-feather="edit-2"></i></a> <a href="#"><i class="align-middle" data-feather="trash"></i></a> </td> </tr> </tbody> <tfoot> <tr> <th>ID</th> <th>FirstName</th> <th>LastName</th> <th>Username</th> <th>Phone #</th> <th>Location</th> <th>Title</th> <th>Role</th> </tr> </tfoot> </table>
|