| | |
Need Contact Us form using PHP Script
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Thread Solved |
•
•
Join Date: Apr 2009
Posts: 13
Reputation:
Solved Threads: 0
Hi,
I have just inherited a website with an existing contact us form. however, it isn't doing what is should and I can't work out why.
Does anyone know of a simple script with 4 fields (Name, Phone, Email and Comments) which I can simply insert into the existing contact us page.
i can post the existing code is neccessary.
regards
I have just inherited a website with an existing contact us form. however, it isn't doing what is should and I can't work out why.
Does anyone know of a simple script with 4 fields (Name, Phone, Email and Comments) which I can simply insert into the existing contact us page.
i can post the existing code is neccessary.
regards
•
•
Join Date: Apr 2009
Posts: 13
Reputation:
Solved Threads: 0
No Database. webserver is running linux with PHP v5 and. All I want is for the form to send an email to a particular email address.
•
•
Join Date: Oct 2007
Posts: 9
Reputation:
Solved Threads: 1
Consult this but need some refining (it uses tables in html), php part works but it might need more security improvement, and encoding things, etc.
Here is the link:
http://www.phpeasystep.com/phptu/8.html
Here is the link:
http://www.phpeasystep.com/phptu/8.html
Last edited by woozy; Jun 4th, 2009 at 10:03 am.
•
•
Join Date: Apr 2009
Posts: 134
Reputation:
Solved Threads: 19
php Syntax (Toggle Plain Text)
<?php //========================================================================================================== // post variables (get the data) //========================================================================================================== $name1 = $_POST['name']; $phone1 = $_POST['phone']; $email1 = $_POST['email']; $comment1 = $_POST['comment']; //========================================================================================================== // if name one is not empty make an email and send it //========================================================================================================== if ($name1) { //========================================================================================================== // need to have pear installed //========================================================================================================== require_once "Mail.php"; $from = "Admin <addyitcomefrom@yourwebsite.com>"; $to = "youremail@yourwebsite.com"; $subject = "subject goes here"; $body = "name: $name \n\n phone: $phone \n\n email: $email \n\n comment: $comment \\n"; $host = "mail.mailserver.com"; $username = "username"; $password = "password"; $headers = array ('From' => $from, 'To' => $to, 'Subject' => $subject); $smtp = Mail::factory('smtp', array ('host' => $host, 'auth' => true, 'username' => $username, 'password' => $password)); $mail = $smtp->send($to, $headers, $body); if (PEAR::isError($mail)) { echo("<p>" . $mail->getMessage() . "</p>"); } else { echo("<p>Message successfully sent!</p>"); } } //========================================================================================================== // make table / form and such //========================================================================================================== echo "<form name='input' action='form.php' method='post'> <p align='center'><table> <tr> <td>NAME:</td> <td><input name='name' type='text' /></td> </tr> <tr> <td>PHONE:</td> <td><input name='phone' type='text' /></td> </tr> <tr> <td>EMAIL:</td> <td><input name='email' type='text' /></td> </tr> <tr> <td>COMMENTS:</td> <td><textarea name='comment' cols='10' rows='10' wrap='ON'></textarea></td> </tr> </table></p> <p align='center'><input type='submit' /></p> </form>"; ?>
Last edited by HITMANOF44th; Jun 4th, 2009 at 10:04 am.
•
•
Join Date: Oct 2007
Posts: 9
Reputation:
Solved Threads: 1
Yep, PEAR provides much more robust solution. But the native solution is as easy as this:
PHP Syntax (Toggle Plain Text)
<?php // Contact subject $subject ="$subject"; // Details $message="$detail"; // Mail of sender $mail_from="$customer_mail"; // From $header="from: $name <$mail_from>"; // Enter your email address $to ='someone@somewhere.com'; $send_contact=mail($to,$subject,$message,$header); // Check, if message sent to your email // display message "We've recived your information" if($send_contact){ echo "We've recived your contact information"; } else { echo "ERROR"; } ?>
Last edited by woozy; Jun 4th, 2009 at 10:09 am.
![]() |
Similar Threads
- 'Tell a friend' form for my PHP script (Web Development Job Offers)
- displaying a form within a php script (PHP)
- contact form (PHP)
- php syntax error (PHP)
- Contact form Flash/PHP sends with Text Formatting (PHP)
- PHP Contact Form Help (PHP)
Other Threads in the PHP Forum
- Previous Thread: Script needed: To 21 users, who each have access to certain dloads! Plz
- Next Thread: fsockopen error
| Thread Tools | Search this Thread |
apache api array beginner binary broken cache cakephp checkbox class cms code codingproblem cron curl customizableitems database date display dynamic echo email error errorlog file files filter folder form format forms forum function functions gc_maxlifetime global google headmethod host href htaccess html image include insert ip javascript joomla limit link login mail malfunctioning memmory memory menu mlm multiple mysql nodes oop parameter parsing paypal pdf php phpmysql problem query radio random recursion recursiveloop remote script search select server sessions sms snippet source space sql static survey syntax system table trouble tutorial up-to-date update upload url validator variable video web youtube





