Could someone please check my scripting for PHP

this is my first PHP and i was wondering if someone would comment on if this is right or not.

<?PHP
$to = "proimageresumes@yahoo.com";
$subject = "Referal Program"
$header = "From: $name <$email>";

$msg = "$name1

";
$msg .= "$email1

";
$msg .= "$phone1

"; 
$msg .= "$contact1

";
$msg .= "$email1

"; 
$msg .= "$name2

";
$msg .= "$email2

";
$msg .= "$phone2

"; 
$msg .= "$contact2

";
$msg .= "$email2'1

"; 
$msg .= "$comments

"; 


mail($to, $subject, $header, $msg, "From: $name
Reply-To: $email
");
?> 

i have noticed that some people have the subject and header at the end of the script – does this make a difference? can i leave it at the top?

then on my time line i have this code inserted

[AS]stop();
Selection.setFocus(nameSpot);[/AS]

and then for my submit button i have this:

[AS]on (release) {
if (name1 eq “” or phone1 eq “” or email1 eq “” or
contact1 eq “” or comments eq “” or name2 eq “” or phone2 eq “” or email2 eq"" or contact2 eq “”)
{
stop ();
}
else
{
loadVariablesNum (“referal.php”, 0, “POST”);
gotoAndStop (2);
}
}[/AS]

now do i need to add anything into my main html page for PHP or will this do it?

thanks guys

Looks fine to me - have you tried it? Don’t forget a semicolon after $subject = “Referal Program” in your PHP script. You’d get a parse error otherwise. And, no, nothing has to be in your HTML with the flash movie to have it work.

You may also want to add this to the beginning of your php file:


$name=$_POST["name"];
$email=$_POST["email"];
$name1=$_Post["name1"];
//etc..etc..for all your variables comming in

no – ihavent had a chance to test it yet, my host doesnt support PHP – so i am looking for a new one, i just wanted to have it ready.

okay i made the changes – did i get it right (i wasnt sure what you meant by putting at the start of my PHP

<?PHP


$name=$_POST["name"];
$email1=$_POST["email1"];
$phone1=$_POST["phone1"];
$contact1=$_POST["contact1"];
$name2=$_POST["name2"];
$email2=$_POST["email2"];
$phone2=$_POST["phone2"];
$contact2=$_POST["contact2"];
$comments=$_POST["comments"];


$to = "proimageresumes@yahoo.com";
$subject = "Referal Program";
$header = "From: $name <$email>";

$msg = "$name1

";
$msg .= "$email1

";
$msg .= "$phone1

"; 
$msg .= "$contact1

";
 
$msg .= "$name2

";
$msg .= "$email2

"; 
$msg .= "$phone2

"; 
$msg .= "$contact2

";

$msg .= "$comments

"; 


mail($to, $subject, $header, $msg, "From: $name
Reply-To: $email
");
?> 

i separated them so i didnt confuse myself by mis-typing something snirt

where does the var $email come from? If it’s posted it needs to be in that list in the beginning. Other than that, it looks good.

I don’t know about your email command. I thought that the order went like:


mail($to, $subject, $message, $header);

I don’t know what that other thing would do. I double checked with this:
http://www.kirupaforum.com/forums/showthread.php?s=&threadid=17604&highlight=PHP+tutorial

which $email var are you talking about.

this one:
1.

$header = "From: $name <$email>";

or this one:

mail($to, $subject, $msg, $header, "From: $name
Reply-To: $email
");

my thinking was that it was the person sending it to me – but i do kinda see what you are talking about – i just dont know how to fix it.

p.s. whadaya know – i just made member status – waaaaaahooooo! i am movin up in the world.

okay — i think i know what you are talking about.

does the ‘mail(to…’ need to be the same as the header

in otherwords

$header = "From: $name <$email>";
mail($to, $subject, $msg, $header, "From: $name <$email>");
?> 

rather than what i had before

$header = "From: $name <$email>";
mail($to, $subject, $msg, $header, "From: $name
Reply-To: $email
");

First off, congrats on your new status - you’ll make a fine member :stuck_out_tongue:

Secondly, the only way you are going to know who fills out your form by email address is for them to actually fill out a box with their email address. It’s not possible for anything to read someone’s email address from a browser. Therefore, it needs to be treated like any other variable coming in to the PHP script from Flash…and I was talking about both of them because they would be empty variables when you ran the script.

For your last thing, I think I mentioned it before, but I don’t know if that added line would do anything in the mail command. I have always just used:


mail($to, $subject, $msg, $header);

However, I think we may have cleared that up seeing that you aren’t going to know who it’s from automatically!! :stuck_out_tongue:

also:
$name=$_POST[“name”];
versus
$msg = "$name1

";
=>either name, or name1 …

If you want to start PHP, cool, it’s not hard, very much like Actionscript…but you’ll get lots of errors for stupid typos & missing semicolons and have to be very carefull with variable names, coz they are case-sensitive in PHP (myvar != Myvar) !!

you are most definately right about typos and such – on the first lines of each (name and name1) they were both supposed to be name1 (i just forgot to add it in)

and you answered another question of mine. case sensitivity. thanks

but i redid it and used name and candidate (it is a referal form they are filling out so it has to be 2 different names listed.)