might be somethingOh, by the way, I don't have MySql, but I didn't want to take that out until I knew what I was doing.
Simple Forms with php
Moderator: General Moderators
-
Illusionist
- Forum Regular
- Posts: 903
- Joined: Mon Jan 12, 2004 9:32 pm
Morning,
I have put a link on my links page to go the test.php. Something does come up, so maybe that will provide clues.
Go to http://www.ameechapman.com/index2.html and hit the links page, at the bottom of that there is the text "test"
Am I right in assuming after looking at that info page that I have to change the method to GET instead of POST? Just trying to learn what's going on.
Thanks
I have put a link on my links page to go the test.php. Something does come up, so maybe that will provide clues.
Go to http://www.ameechapman.com/index2.html and hit the links page, at the bottom of that there is the text "test"
Am I right in assuming after looking at that info page that I have to change the method to GET instead of POST? Just trying to learn what's going on.
Thanks
Well, somethings 'going wrong' but without any output at all it's hard to know where to begin looking, so the first thing is to try to get some output going. The test page shows that display_errors is Off, so lets turn that On.
In contact.php right under the line (at the top) that says
error_reporting(E_ALL);
add
ini_set('display_errors', 1);
See if that helps any.
In contact.php right under the line (at the top) that says
error_reporting(E_ALL);
add
ini_set('display_errors', 1);
See if that helps any.
Hmmmmm....we have error_reporting set to E_ALL, display_errors are On and the first line(s) are a simple echo, then i can't see why it wouldn't display at least 'something'. On the server, can you copy contact.php to a file called contact.phps , this way we can see the actual source code. But i'm running out of ideas... 
OK, so I switched back to an old form I was using that didn't work. I connected the contact form to a php called form_emailer. I then gave the form an action (the php) and it actually does what it is supposed to do, sort of. I get an e-mail, from the form, but the info is missing. Looks something like this:
Senders Name:
=================
Senders Mailing Address:
=================
Senders Email:
=================
Senders Phone Number:
=================
Senders Fax Number:
=================
Senders Comments:
=================
Senders Browser:
=================
Senders IP Number:
=================
127.0.0.1
But I am hopeful that this one will be easier. I will post the php code and see if anyone can come up with the solution. Thanks again. Once I learn this, I will be able to work on my non-profits website to do the same thing.[/php_man]<?php
?>
Senders Name:
=================
Senders Mailing Address:
=================
Senders Email:
=================
Senders Phone Number:
=================
Senders Fax Number:
=================
Senders Comments:
=================
Senders Browser:
=================
Senders IP Number:
=================
127.0.0.1
But I am hopeful that this one will be easier. I will post the php code and see if anyone can come up with the solution. Thanks again. Once I learn this, I will be able to work on my non-profits website to do the same thing.
Code: Select all
<?php
//Define some variables
$youremail="amee@sierraadoption.org"; // This is the address that the information submitted will be sent to.
$emailsubject="Website Contact form info!"; // This will be the email's subject
// The From field will be be where this email came from.
// Note on the from field. the text after the first " mark, until the < is what appears in "From" in your email program.
// So, you can put anything alpha numeric here. That would be any letters A-Z and a-z, as well as 0-9
$from_who="AmeeChapman Contact Form <amee@ameechapman.com>";
$pagetitle="Thank You!"; // Title to be displayed on the sent info page.
// Enter the code that you want to appear before the information submitted.
// Make sure you put a / mark before all double quotation marks or the script won't work.
// the \n at the end of the line is to create a new line in the HTML SOURCE. It DOES NOT create a break or new line
// when viewing it on the internet. Put these at the end of each line in the header and footer if you wish.
// They aren't required.
$header = "<!-- Begin Header -->\n
<table>\n
<tr>\n
<td bgcolor="000000"><font color="FFFFFF" size="2" face="verdana">\n
<!-- End Header -->\n";
// Enter the code you'd like displayed after the information submitted.
// Make sure you put a / mark before all double quotation marks or the script won't work.
// the \n at the end of the line is to create a new line in the HTML SOURCE. It DOES NOT create a break or new line
// when viewing it on the internet. Put these at the end of each line in the header and footer if you wish.
// They aren't required.
$footer = "<!-- Begin Footer -->\n
</td></tr></table>\n
<!-- End Footer -->\n";
// This code gets the ip address of the person submiting the form.
// You shouldn't remove it if you want to use this feature.
if (getenv(HTTP_CLIENT_IP)){
$user_ip=getenv(HTTP_CLIENT_IP);
}
else {
$user_ip=getenv(REMOTE_ADDR);
}
// If your server uses php version 4.2 or above, you can leave this section alone.
// Otherwise, add 2 slashes (//) to the beginning of the following 4 lines and delete the // in the section below.
//$requiredname = $_POST['requiredname'];
//$mailingaddress = $_POST['mailingaddress'];
//$email = $_POST['email'];
//$requiredphone = $_POST['requiredphone'];
//$fax = $_POST['fax'];
//$message = $_POST['message'];
//$firstname = $HTTP_POST_VARS['firstname'];
//$email = $HTTP_POST_VARS['email'];
//$url = $HTTP_POST_VARS['url'];
//$comments = $HTTP_POST_VARS['url'];
// Edit the following lines to customize how the email sent to you will look.
// To add more fields, just copy and paste the line, and edit the info between the " marks.
// The last 2 lines will send the users browser information and their ip number with the mail.
// Just in case.
$mailbody="Senders Name:\n=================\n$requiredname\n\n";
$mailbody.="Senders Mailing Address:\n=================\n$mailingaddress\n\n";
$mailbody.="Senders Email:\n=================\n$email\n\n";
$mailbody.="Senders Phone Number:\n=================\n$requiredphone\n\n";
$mailbody.="Senders Fax Number:\n=================\n$fax\n\n";
$mailbody.="Senders Comments:\n=================\n$message\n\n";
$mailbody.="Senders Browser:\n=================\n$HTTP_USER_AGENT\n\n";
$mailbody.="Senders IP Number:\n=================\n$user_ip\n\n";
mail("$youremail", "$emailsubject", "$mailbody", "From: $from_who"); // Send the email.
$comments = nl2br($comments);
// Page HTML comes next.
?>
<html>
<head>
<title><?php $pagetitle ?></title>
</head>
<body>
<?php print $header;
// A note about the following.
// Each of the printed values here correspond to a field in the form.
// Change this area if you change what fields are in the form.
?>
Thank You!
Your message was sent to Amee and she'll reply as soon as she can!<br>
<?php print $footer; ?>
</body>
</html>?>
Your server is using PHP 4.3.4 so you need to remove the 2 slashes from the lines below the above text, so you end up with :// If your server uses php version 4.2 or above, you can leave this section alone.
// Otherwise, add 2 slashes (//) to the beginning of the following 4 lines and delete the // in the section below.
Code: Select all
$requiredname = $_POST['requiredname'];
$mailingaddress = $_POST['mailingaddress'];
$email = $_POST['email'];
$requiredphone = $_POST['requiredphone'];
$fax = $_POST['fax'];
$message = $_POST['message'];
$firstname = $HTTP_POST_VARS['firstname'];
$email = $HTTP_POST_VARS['email'];
$url = $HTTP_POST_VARS['url'];
$comments = $HTTP_POST_VARS['url'];