PHP - Need Help With Php Form To Email Script
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
Similar TutorialsI am using a simple email script called PHPmailer which works great but i would like to create a form so a user can input what the text for the email should be along with the subject from texts boxes, i also need the script to connect to a mysql database to get a list of email address to send to. Then once the user presses the send button the email is sent out to everyone in the database. Can anyone help me? <?php include_once('class.phpmailer.php'); $mail = new PHPMailer(); $body = eregi_replace("[\]",'',$body); $mail->IsSendmail(); // telling the class to use SendMail transport $mail->From = "zac@zpwebsites.com"; $mail->FromName = "First Last"; $mail->Subject = "PHPMailer Test Subject via smtp"; $mail->AltBody = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test $mail->MsgHTML($body); $mail->AddAddress("zacthespack@gmail.com", "John Doe"); $mail->AddAttachment("uploads/AleMail.pdf"); // attachment if(!$mail->Send()) { echo "Mailer Error: " . $mail->ErrorInfo; } else { echo "Message sent!"; } ?> Hi guys, sorry for such a newbish question. Any help would be greatly appreciated. HTML FORM: Code: [Select] <form action="form.php" method="post" onsubmit="return validateForm()" name="form"> <b>First Name:*</b> <input type="text" name="first_name" size="50" /> <b>Last Name:*</b> <input type="text" name="last_name" size="50" /> <b>Phone:*</b> <input type="text" name="phone" size="50" /> <b>Email:*</b> <input type="text" name="email" size="50" /> <p><b>What is your favorite color?*</b></p> <p align="left"> <select name="se"> <option value="W">White</option> <option value="G">Green</option> <option value="Y">Yellow</option> </select> <input type="submit" value="Submit"/> </form> FORM.PHP script Code: [Select] <?php $se = $_POST['se']; $seURL = ''; switch ($se) { case 'W': $seURL = "http://url1.com"; break; case 'G': $seURL = "http://url2.com"; break; case 'O': $seURL = "http://url3.com"; break; default: $seURL = ""; } if ($seURL != "") { /* Redirect browser */ /* make sure nothing is output to the page before this statement */ header("Location: " . $seURL); } // get posted data into local variables $EmailFrom = "noreply@domain.com"; $EmailTo = "email@domain.com"; $Subject = "Form"; $first_name = Trim(stripslashes($_POST['first_name'])); $last_name = Trim(stripslashes($_POST['last_name'])); $phone = Trim(stripslashes($_POST['phone'])); $email = Trim(stripslashes($_POST['email'])); // validation $validationOK=true; if (!$validationOK) { print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">"; exit; } // prepare email body text $Body = ""; $Body .= "first_name: "; $Body .= $first_name; $Body .= "\n"; $Body .= "last_name: "; $Body .= $last_name; $Body .= "\n"; $Body .= "phone: "; $Body .= $phone; $Body .= "\n"; $Body .= "email: "; $Body .= $email; $Body .= "\n"; $Body .= "color: "; $Body .= $se; $Body .= "\n"; // send email $success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>"); // send email to user if ($se=="W") $EmailFrom = "noreply@domain.com"; $to = $email; $subject = "form email"; $body = "thank you for filling out our form"; if (mail($to, $subject, $body, "From: <$EmailFrom>")) { echo("<p>Message successfully sent!</p>"); } else { echo("<p>Message delivery failed...</p>"); } ?> [code] MOD EDIT: [nobbc][code] . . . [/code][/nobbc] tags added . . . 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. So basically here is what Im trying to do: I have a site that has an employee roster on it...this roster obviously has the employees information including their email addresses next to their names. I am trying to create a script that will allow an employee to easily email another employee on the roster simply by clicking the email address for that employee. To sum this up (or make it even more confusing) ... If i have an email address LINK of "myname@company.com" next to an employees name and a person clicks on that link ... I need some code that will take that email address link (myname@company.com) and add it into the email script into the "$to" function so that when they submit the email form it will go to the employees email (myname@company). I have several employee on this roster so I need a universal script that takes the email links information (ie myname@company.com) and puts it into the mail.php script. I do not want to have to make individual email scripts for each employee just to add to change the "$to" variable on each script!!! So basically how do I add a "links information" into a php script ?? Does this make sense ??? Are you confused ?? I can TRY to explain better if need be. I have looked all over the internet for this and have searched this forum however I have not been able to find a solution to this. A step in the right direction would be great!!! 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 Hello, I am working with a SMTP class to send an email. It's all working perfectly fine, but when the email is received (sent from the online form), and I open my email and click reply, there are two email addresses. The correct one (which I entered when I sent the email), and my ftp username for the site?? I've got three files that could effect this, but I was unable to locate any problems: mailer.php ( smtp send mail class) mail.php ( submission data: title, subject, etc. ) contact_form.php ( form for submission ) I am only including the file which I think is applicable (mail.php), but let me know if you would also like to see the mailer.php class. Current output: reply-to ftpusername@domainname.com, correct_from_email@fromemail.com mail.php: <?php set_time_limit(120); function sendHTMLmail($from, $to, $subject, $message) { $message = wordwrap($message, 70); // To send HTML mail, the Content-type header must be set $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; // Additional headers $headers .= "From: $from\r\n"; // Mail it mail($to, $subject, $message, $headers); } function sendHTMLmail2($fromid, $to, $subject, $message) { echo $fromid; echo $to; echo $subject; echo $message; include_once("mailer.php"); $mail = new PHPMailer(); $mail->IsMail(); // SMTP servers $mail->Host = "localhost"; $mail->From = $fromid; $mail->FromName = $fromid; $mail->IsHTML(true); $mail->AddAddress($to, $to); $mail->Subject = $subject; $mail->Body = $message; $mail->AltBody = "Please enable HTML to read this"; $mail->Send(); exit; } function isValidEmail($email) { return eregi("^[_.0-9a-z-]+@([0-9a-z][0-9a-z-]+.)+[a-z]{2,3}$", $email); } class smtp_mail { var $host; var $port = 25; var $user; var $pass; var $debug = false; var $conn; var $result_str; var $charset = "utf-8"; var $in; var $from_r; //mail format 0=normal 1=html var $mailformat = 0; function smtp_mail($host, $port, $user, $pass, $debug = false) { $this->host = $host; $this->port = $port; $this->user = base64_encode($user); $this->pass = base64_encode($pass); $this->debug = $debug; $this->socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP); if ($this->socket) { $this->result_str = "Create socket:" . socket_strerror(socket_last_error()); $this->debug_show($this->result_str); } else { exit("Initialize Faild,Check your internet seting,please"); } $this->conn = socket_connect($this->socket, $this->host, $this->port); if ($this->conn) { $this->result_str = "Create SOCKET Connect:" . socket_strerror(socket_last_error()); $this->debug_show($this->result_str); } else { exit("Initialize Faild,Check your internet seting,please"); } $this->result_str = "Server answer:<font color=#cc0000>" . socket_read($this->socket, 1024) . "</font>"; $this->debug_show($this->result_str); } function debug_show($str) { if ($this->debug) { echo $str . "<p>\r\n"; } } function send($from, $to, $subject, $body) { if ($from == "" || $to == "") { exit("type mail address please"); } if ($subject == "") $sebject = "none title"; if ($body == "") $body = "none content"; $All = "From:$from;\r\n"; $All .= "To:$to;\r\n"; $All .= "Subject:$subject;\r\n"; if ($this->mailformat == 1) { $All .= "Content-Type:text/html;\r\n"; } else { $All .= "Content-Type:text/plain;\r\n"; } $All .= "Charset:" . $this->charset . ";\r\n\r\n"; $All .= " " . $body; $this->in = "EHLO HELO\r\n"; $this->docommand(); $this->in = "AUTH LOGIN\r\n"; $this->docommand(); $this->in = $this->user . "\r\n"; $this->docommand(); $this->in = $this->pass . "\r\n"; $this->docommand(); if (!eregi("235", $this->result_str)) { $this->result_str = "smtp auth faild"; $this->debug_show($this->result_str); return 0; } $this->in = "MAIL FROM: $from\r\n"; $this->docommand(); $this->in = "RCPT TO: $to\r\n"; $this->docommand(); $this->in = "DATA\r\n"; $this->docommand(); $this->in = $All . "\r\n.\r\n"; $this->docommand(); if (!eregi("250", $this->result_str)) { $this->result_str = "Send mail faild!"; $this->debug_show($this->result_str); return 0; } $this->in = "QUIT\r\n"; $this->docommand(); socket_close($this->socket); return 1; } function docommand() { socket_write($this->socket, $this->in, strlen($this->in)); $this->debug_show("Client command:" . $this->in); $this->result_str = "server answer:<font color=#cc0000>" . socket_read($this->socket, 1024) . "</font>"; $this->debug_show($this->result_str); } } ?> Hi the user fill details and then the email his sent to me the only problem is that the emails keeps going to my spam, can someone help me out please I looked already php website and email format looks the same. This is the link to my form. http://www.people.eurico.co.uk/ here my form script Code: [Select] <?php // Set email variables $email_to = 'xxxxx@xxxxxxx.co.uk'; $email_subject = 'Call back form'; // Set required fields $required_fields = array('fullname','email','telephone','comment'); // set error messages $error_messages = array( 'fullname' => 'Please enter a Name to proceed.', 'email' => 'Please enter a valid Email.', 'telephone' => 'Please telephone.', 'comment' => 'Please enter your Message to continue.' ); // Set form status $form_complete = FALSE; // configure validation array $validation = array(); // check form submittal if(!empty($_POST)) { // Sanitise POST array foreach($_POST as $key => $value) $_POST[$key] = remove_email_injection(trim($value)); // Loop into required fields and make sure they match our needs foreach($required_fields as $field) { // the field has been submitted? if(!array_key_exists($field, $_POST)) array_push($validation, $field); // check there is information in the field? if($_POST[$field] == '') array_push($validation, $field); // validate the email address supplied if($field == 'email') if(!validate_email_address($_POST[$field])) array_push($validation, $field); } // basic validation result if(count($validation) == 0) { // Prepare our content string $email_content = 'peoplesmartlearning.co.uk: ' . "\n\n"; // simple email content foreach($_POST as $key => $value) { if($key != 'submit') $email_content .= $key . ': ' . $value . "\n"; } // if validation passed ok then send the email mail($email_to, $email_subject, $email_content); // Update form switch $form_complete = TRUE; } } function validate_email_address($email = FALSE) { return (preg_match('/^[^@\s]+@([-a-z0-9]+\.)+[a-z]{2,}$/i', $email))? TRUE : FALSE; } function remove_email_injection($field = FALSE) { return (str_ireplace(array("\r", "\n", "%0a", "%0d", "Content-Type:", "bcc:","to:","cc:"), '', $field)); } ?> The HTML Code: [Select] <div class="call_us_form"> <p class="title">WE'LL CALL YOU BACK</p> <?php if($form_complete === FALSE): ?> <form class="contact_form" id="fm-form" method="post" action="index.php" > <fieldset> <div class="fm-req"> <label for="fm-firstname">Name</label> <input type="text" id="fullname" class="detail" name="fullname" value="<?php echo isset($_POST['fullname'])? $_POST['fullname'] : ''; ?>" /> <?php if(in_array('fullname', $validation)): ?><script type="text/javascript">alert("Please enter a Name"); history.back();</script><?php endif; ?> </div> <div class="fm-req"> <label for="fm-firstname">Email</label> <input type="text" id="email" class="detail" name="email" value=" <?php echo isset($_POST['email'])? $_POST['email'] : ''; ?>" /> <?php if(in_array('email', $validation)): ?><script type="text/javascript">alert("Please enter a valid Email Address"); history.back();</script><?php endif; ?> </div> <div class="fm-req"> <label for="fm-firstname">Number</label> <input type="text" id="telephone" class="detail" name="telephone" value="<?php echo isset($_POST['telephone'])? $_POST['telephone'] : ''; ?>" /> <?php if(in_array('telephone', $validation)): ?><script type="text/javascript">alert("Please enter telephone number"); history.back();</script><?php endif; ?> </div> <div class="fm-req"> <label for="fm-lastname">Message</label> <textarea cols="40" rows="5" id="comment" name="comment" class="mess"><?php echo isset($_POST['comment'])? $_POST['comment'] : ''; ?></textarea> <?php if(in_array('comment', $validation)): ?><script type="text/javascript">alert("Please enter your message"); history.back();</script><?php endif; ?> </div> <input class="submit_button" type="submit" value="Call us" /> </fieldset> </form> <?php else: ?> <p>Thank you for your Message!</p> <p>We will get back to you as soon as we can</p> <script type="text/javascript"> setTimeout ('ourRedirect()', 5000) function ourRedirect () { location.href='index.php' } </script> <?php endif; ?> Hi all, What I am trying to achieve is, I thought quite simple! Basically, a user signs up and chooses a package, form is submitted, details added to the database, email sent to customer, then I want to direct them to a paypal payment screen, this is where I am having issues! Is their any way in php to submit a form without user interaction? Here is my code for the form process page Code: [Select] <?php include('config.php'); require('scripts/class.phpmailer.php'); $package = $_POST['select1']; $name = $_POST['name']; $email = $_POST['email']; $password = md5($_POST['password']); $domain = $_POST['domain']; $a_username = $_POST['a_username']; $a_password = $_POST['a_password']; $query=mysql_query("INSERT INTO orders (package, name, email, password, domain, a_username, a_password) VALUES ('$package', '$name', '$email', '$password', '$domain', '$a_username', '$a_password')"); if (!$query) { echo "fail<br>"; echo mysql_error(); } else { $id = mysql_insert_id(); $query1=mysql_query("INSERT INTO customers (id, name, email, password) values ('$id', '$name', '$email', '$password')"); if (!$query1) { echo "fail<br>"; echo mysql_error(); } if($package=="Reseller Hosting") { //email stuff here - all works - just cutting it to keep the code short if(!$mail->Send()) { echo "Message could not be sent. <p>"; echo "Mailer Error: " . $mail->ErrorInfo; exit; } ?> <form name="_xclick" action="https://www.paypal.com/cgi-bin/webscr" method="post"> <input type="hidden" name="cmd" value="_xclick-subscriptions"> <input type="hidden" name="business" value="subscription@jollyhosting.com"> <input type="hidden" name="currency_code" value="USD"> <input type="hidden" name="item_name" value="Jolly Hosting Reseller Packages"> <input type="hidden" name="no_shipping" value="1"> <!--1st month --> <input type="hidden" name="currency_code" value="USD"> <input type="hidden" name="a3" value="3.00"> <input type="hidden" name="p3" value="1"> <input type="hidden" name="t3" value="M"> <input type="hidden" name="src" value="1"> <input type="hidden" name="sra" value="1"> </form>'; <?php } //last } //end ?> 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>"); } ?> 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 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 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 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. 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> 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 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 |