===========email=============
Hello!
Thank you for reaching out. We will be in contact with you as soon as possible!:
Name:
E-mail:
Account-Number:
Ticket Number: 814
Message:
Hello!
Your contact form has been submitted by:
Name:
E-mail:
Account-Number:
IP:
Message:
Testing of the 2way mesage system
End of message
End of message
======CODE=========
Expand|Select|Wrap|Line Numbers
- <?php
- /* Set e-mail recipient */
- $myemail = "";
- /* Get submitent ip address */
- $ip=$_SERVER['REMOTE_ADDR'];
- /* Check all form inputs using check_input function */
- $name = check_input($_POST['name'], "Enter your name");
- $subject = check_input($_POST['subject']);
- $email = check_input($_POST['email']);
- $acctnum = check_input($_POST['acctnum']);
- $message = check_input($_POST['message'], "Write your comments");
- /* If e-mail is not valid show error message */
- if (!preg_match("/([\w\-]+\@[\w\-]+\.[\w\-]+)/", $email))
- {
- show_error("E-mail address not valid");
- }
- /* Generate ticket number */
- $ticketnum = mt_rand(1,1000);
- /* Let's prepare the message for the e-mail */
- $message = "Hello!
- Your contact form has been submitted by:
- Name: $name
- E-mail: $email
- Account-Number: $acctnum
- IP: $ip
- Message:
- $message
- End of message
- ";
- /* Prepare the email to the client */
- $subject2 = "Ticket: $ticketnum";
- $message2 = "Hello!
- Thank you for reaching out. We will be in contact with you as soon as possible!:
- Name: $name
- E-mail: $email
- Account-Number: $acctnum
- Ticket Number: $ticketnum
- Message:
- $message
- End of message
- ";
- /* send emails */
- mail($myemail, $subject, $message);
- mail($email, $subject2, $message2);
- /* Redirect visitor to the thank you page */
- header('Location: ../thanks.html');
- exit();
- /* Functions we used */
- function check_input($data, $problem='')
- {
- $data = trim($data);
- $data = stripslashes($data);
- $data = htmlspecialchars($data);
- if ($problem && strlen($data) == 0)
- {
- show_error($problem);
- }
- return $data;
- }
- function show_error($myError)
- {
- ?> <html> <body> <b>Please correct the following error:</b><br /> <?php echo $myError; ?> </body> </html> <?php
- exit();
- }
- ?>