Jump to content

Does anyone know what the php program does?


sweetpe

Recommended Posts

<?php

  //

  $name=$_POST['name'];

  $email=$_POST['email'];

  $feedback=$_POST['feedback'];

 

  $toaddress = '[email protected]';

 

  //

  if (stristr($feedback, 'shop'))

  $toaddress = 'retail@example'.com;

  else if (stristr($feedback, 'delivery'))

  $toaddress = '[email protected]';

  else if (stristr($feedback, 'bill'))

  $toaddress = '[email protected]';

 

  //

  if (!eregi('^[a-zA-Z0-9_\-\.]+@[a-zA-Z0-9_\-]+\.[a-zA-Z0-9_\-\.]+$', $email))

  {

echo 'That is not a valid email address.  Please return to the'

.' previous page and try again.';

exit;

  }

 

  $subject = 'Feedback from web site';

  $mailcontent = 'Customer name: '.$name."\n"

                .'Customer email: '.$email."\n"

                ."Customer comments: \n".$feedback."\n";

  $fromaddress = 'From: [email protected]';

 

  mail($toaddress, $subject, $mailcontent, $fromaddress);

?>

<html>

<head>

  <title>Bob's Auto Parts - Feedback Submitted</title>

</head>

<body>

<h1>Feedback submitted</h1>

<p>Your feedback has been sent.</p>

 

</body>

</html>

psuedocode  :)

 

$name = post variable name (i.e. <input name="name">)

$email = post variable email

$feedback = post variable name

 

$toaddress = '[email protected]';

 

if shop is in variable feedback then $toaddress = '[email protected]'

else if delivery is in variable feedback then $toaddress = '[email protected]';

else if bill is in variable feedback then  $toaddress = '[email protected]';

 

check if variable emailis valid (some string + @ + some string + . + some string)

if email is not valid show error message and quit.

 

set mail subject, body, and from address

 

send mail to $toaddress with subject $subject body $mailcontent and from address $fromaddress

 

display html page saying that content was submitted.

 

by the way 'retail@example'.com; should be '[email protected]';

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.