Hi,
This will be either the 5th or 6th (largely populated) PHP Help forum I've come to in hopes of getting to talk with someone that is willing and capable of conversing with a newbie who really just doesn't understand.
So I've been trying for a week or so to get this contact form to work even REMOTELY... not even tweak it to the way I want. But getting a response is impossible. All the large forums after someone says their peace the thread is never checked again so I'm left with all these suggestions but more questions.
In any case I'm trying to get a few things working... first the form doesn't even send mail. The if / else I have in it doesn't seem to be working either. Or it doesn't function. The way it was setup I was told was using globals which is turned off. So the recent suggestion I have received is where i'm having problems.
Above any and all HTML in the document I have this...
<?php
if($submit)
{
mail("name@site.com", "$subject", "$message", "From: $mail", "To: $radiobutton");
}
?>
Then I have in a row right in the same position the form would place is...
<?php if($submit) { ?>
After this shows some HTML for a Thank You for your Submission if everything went a-ok.
Then I have this for the Form.
<?php } else { ?>
This is now the form... there is =
<form action="contact.php" method="post" name="contact" id="contact">
Name:
E-mail:
(Drop Down Subject Selection)
Message:
(Radio Buttons for where they want this e-mail directed)
Finally at the end of the table where the form resides I have
<?php } ?>
This is how I had it setup... but then I was told about globals... so I changed it to this.
This is what he said to do... except I don't precisely where to put it in. I've tried a few things but only get error on line (##)
If you've got a button called 'submit' which says "Send Now!", clicking the button will generate the following:
$_POST['submit'] = "Send Now";
So to cut the long story short, all you need to do is to capture what is in the $_POST superglobal.
In your code, start by doing the following:
$submit = $_POST['submit']...Do the same for all the variables you've got. In other words, rather than assume that PHP will automatically generate things like $firstname from a textbox called 'firstname', you must start by grabbing it from the $_POST, eg
$firstname = $_POST['firstname'] etc, etc.
Then you can go ahead and code as before.
So... this is what I have now... no errors, but it still isn't working.
<?php
$submit = $_POST['submit'];
$subject = $_POST['subject'];
$name = $_POST['name'];
$mail = $_POST['mail'];
$radiobutton = $_POST['radiobutton'];
if($submit)
{
mail("name@name.com", "$subject", "$message", "From: $mail", "Name: $name", "To: $radiobutton");
}
?>
Can someone kind of give me some hints / tips and explain a few things as to How I would implement the alternate to globals. Like the above stated.
And maybe some suggestions to make it better. Optimized or whatever. I'd GREATLY appreciate it. I am running out of forums to visit.