Php script not working

Get help on web editors (Frontpage, Dreamweaver) and web languages (HTML, ASP, PHP).
maxxis
Moderator Emeritus
Posts: 8307
Joined: 30 Jun 2004, 02:00
Location: ( . Y . )
Contact:

Re: Php script not working

Post by maxxis »

What type of validation?

Required or Captcha?
CesarePlay
Registered User
Posts: 10628
Joined: 26 Mar 2007, 02:00
Location: In the river of thoughts
Contact:

Re: Php script not working

Post by CesarePlay »

Required and filled in incorrectly.
Image
maxxis
Moderator Emeritus
Posts: 8307
Joined: 30 Jun 2004, 02:00
Location: ( . Y . )
Contact:

Re: Php script not working

Post by maxxis »

Google it.
CesarePlay
Registered User
Posts: 10628
Joined: 26 Mar 2007, 02:00
Location: In the river of thoughts
Contact:

Re: Php script not working

Post by CesarePlay »

I did. I did not find what I wanted so I bought a book instead.
Image
maxxis
Moderator Emeritus
Posts: 8307
Joined: 30 Jun 2004, 02:00
Location: ( . Y . )
Contact:

Re: Php script not working

Post 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);

}
CesarePlay
Registered User
Posts: 10628
Joined: 26 Mar 2007, 02:00
Location: In the river of thoughts
Contact:

Re: Php script not working

Post 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.
Image
CyBeR AssassiN
Registered User
Posts: 24
Joined: 14 Dec 2008, 19:26
Location: JHB - Germiston
Contact:

Re: Php script not working

Post by CyBeR AssassiN »

In PHP scripts.. htaccess file, the register globals must be on, not off and all text files must be chmod 777
Best free downloads portal & Community: DotWorld Mobile!
http://wap.dotworldnet.net

Code: Select all

try {
    printObject(new help('need_php_help'));
} catch(NullHandleException $exception) {
    print $exception->getMessage();
    print 'Error... Search before asking questions! '.$exception->getFile();
}
SLYF3R
Registered User
Posts: 1
Joined: 16 Jan 2009, 16:01

Re: Php script not working

Post 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.

:)
Post Reply