Page 2 of 2

Re: Php script not working

Posted: 19 Sep 2008, 15:32
by maxxis
What type of validation?

Required or Captcha?

Re: Php script not working

Posted: 19 Sep 2008, 15:40
by CesarePlay
Required and filled in incorrectly.

Re: Php script not working

Posted: 19 Sep 2008, 15:41
by maxxis
Google it.

Re: Php script not working

Posted: 23 Sep 2008, 06:57
by CesarePlay
I did. I did not find what I wanted so I bought a book instead.

Re: Php script not working

Posted: 23 Sep 2008, 10:56
by maxxis
Replace the processor page with this code.

Code: Select all

oreach ($_POST as $k=>$v) {
        if ($v==''&&$k!='url') {
          $err.="The ".$k." field cannot be blank<br/>";
        } // end if
      }
      if (isset($err)&&$err!='') {
echo $err;
      } else {

//$httpagent = $_POST['httpagent'];
$httpref = $_POST['$httpref'];
$recipient = "xyz@zy.com";
$fullname = $_POST['fullname'];
$idnumber = $_POST['idnumber'];
$Physicaladdress = $_POST['physicaladdress'];
$Postaladdress = $_POST['postaladdress'];
$Telephonehome = $_POST['telephonehome'];
$Telephonework = $_POST['telephonework'];
$Cell = $_POST['Cell'];
$Join = $_POST['Join'];
$From = "www.website.net";
$comments = $_POST['comments'];
$todayis = date("l, F j, Y, g:i a") ;
$subject = "Bill of Animal Rights";

$message = "Today's date is: $todayis";
$message = "Name: $fullname";
$message .= "ID Number: $idnumber";
$message .= "Physical Address: $Physicaladdress";
$message .= "Postal Address: $Postaladdress";
$message .= "Telephone (home): $Telephonehome";
$message .= "Telephone (work): $Telephonework";
$message .= "Cell Number: $Cell";
$message .= "Join ABVP Law?: $Join";
$message .= "Comments: $comments";

mail($recipient,$subject,$message,$From);

// Page Notification
$notificationPage   = "http://www.website.htm";

//redirect here
// Notification

$exit_location = "Location: ".$notificationPage;
header($exit_location);

}

Re: Php script not working

Posted: 23 Sep 2008, 11:04
by CesarePlay
maxxis wrote:Replace the processor page with this code.

Code: Select all

oreach ($_POST as $k=>$v) {
        if ($v==''&&$k!='url') {
          $err.="The ".$k." field cannot be blank<br/>";
        } // end if
      }
      if (isset($err)&&$err!='') {
echo $err;
      } else {

//$httpagent = $_POST['httpagent'];
$httpref = $_POST['$httpref'];
$recipient = "xyz@zy.com";
$fullname = $_POST['fullname'];
$idnumber = $_POST['idnumber'];
$Physicaladdress = $_POST['physicaladdress'];
$Postaladdress = $_POST['postaladdress'];
$Telephonehome = $_POST['telephonehome'];
$Telephonework = $_POST['telephonework'];
$Cell = $_POST['Cell'];
$Join = $_POST['Join'];
$From = "www.website.net";
$comments = $_POST['comments'];
$todayis = date("l, F j, Y, g:i a") ;
$subject = "Bill of Animal Rights";

$message = "Today's date is: $todayis";
$message = "Name: $fullname";
$message .= "ID Number: $idnumber";
$message .= "Physical Address: $Physicaladdress";
$message .= "Postal Address: $Postaladdress";
$message .= "Telephone (home): $Telephonehome";
$message .= "Telephone (work): $Telephonework";
$message .= "Cell Number: $Cell";
$message .= "Join ABVP Law?: $Join";
$message .= "Comments: $comments";

mail($recipient,$subject,$message,$From);

// Page Notification
$notificationPage   = "http://www.website.htm";

//redirect here
// Notification

$exit_location = "Location: ".$notificationPage;
header($exit_location);

}
Ok. Thanks. I got validation to work with Javascript but I bear that code in mind for my site.

Re: Php script not working

Posted: 02 Jan 2009, 16:02
by CyBeR AssassiN
In PHP scripts.. htaccess file, the register globals must be on, not off and all text files must be chmod 777

Re: Php script not working

Posted: 16 Jan 2009, 20:35
by SLYF3R
I would like to say hello.

I have been struggeling to solve a client's mail script problem for a week straight. Till I got fed up and started learning php. While learning php, i were trying to write my own mail script. Thanks to a weeks hard work I learnt php in a flash and I can basically write my own php mail form with validation in the same php file and contains some script for catcha proccessing also. And as compact as hell.

Enough of explaining for a bit. Now here is what i did with the script. It works like a charm when i was done with it. Here is the code. No validation and captcha included yet:

<?php

$httpagent = $_POST["httpagent"];
$httpref = $_POST["httpref"];
$recipient = "test@test.co.za";
$fullname = $_POST["fullname"];
$idnumber = $_POST["idnumber"];
$Physicaladdress = $_POST["physicaladdress"];
$Postaladdress = $_POST["postaladdress"];
$Telephonehome = $_POST["telephonehome"];
$Telephonework = $_POST["telephonework"];
$Cell = $_POST["Cell"];
$Join = $_POST["Join"];
$From = "From: Your Website's Name";
$comments = $_POST["comments"];
$todayis = date("l, F j, Y, g:i a");
$subject = "Bill of Animal Rights";

// Page Notification
$notificationPage = "http://www.mycreativedesigns.co.za";

$message = "Today's date is: " . $todayis . "\r\n";
$message .= "Name: " . $fullname . "\r\n";
$message .= "ID Number: " . $idnumber . "\r\n";
$message .= "Physical Address: " . $Physicaladdress . "\r\n";
$message .= "Postal Address: " . $Postaladdress . "\r\n";
$message .= "Telephone (home): " . $Telephonehome . "\r\n";
$message .= "Telephone (work): " . $Telephonework . "\r\n";
$message .= "Cell Number: " . $Cell . "\r\n";
$message .= "Join ABVP Law?: " . $Join . "\r\n";
$message .= "Comments: " . $comments . "";

mail($recipient,$subject,$message,$From);

// Notification
header("Location: " . $notificationPage);

?>

I have my own domain which i tested it with. Here is what it printed out on my email when i tested it:

Today's date is: Friday, January 16, 2009, 8:08 pm
Name: Nameless
ID Number: 1234567890123
Physical Address: walk str, Wherever, 1234
Postal Address: PO Box 123, Wherever, 1234
Telephone (home): 12345678901
Telephone (work): 1234567890
Cell Number: 1234567890
Join ABVP Law?: yes
Comments: Hello :)

The headers looked like this:

From: Your Website's Name
To: test@test.co.za(I changed only the email address for protection)
Subject: Bill of Animal Rights

So yeah it worked like a charm.
----------------------------

Next you would like to add validation. The captcha will come later. Cheers for now. I hope you enjoy the script now, because it will work. There were some scripting problems here and there but no real major problem. Will send you your script with validation soon.

:)