# Could someone please check my scripting for PHP

**URL:** <https://forum.kirupa.com/t/could-someone-please-check-my-scripting-for-php/29113>\
**Category:** Uncategorized\
**Created:** [August 22, 2003, 11:54am UTC](https://forum.kirupa.com/t/could-someone-please-check-my-scripting-for-php/29113 "2003-08-22T11:54:02Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![urbaneve](https://avatars.discourse-cdn.com/v4/letter/u/839c29/32.png) [@urbaneve](https://forum.kirupa.com/u/urbaneve)\
**Post date:** [August 22, 2003, 11:54am UTC](https://forum.kirupa.com/t/could-someone-please-check-my-scripting-for-php/29113/1 "2003-08-22T11:54:02Z")

</div>

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

```php
<?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

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [August 22, 2003, 8:23pm UTC](https://forum.kirupa.com/t/could-someone-please-check-my-scripting-for-php/29113/2 "2003-08-22T20:23:15Z")

</div>

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:

```php

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

```

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [August 22, 2003, 9:34pm UTC](https://forum.kirupa.com/t/could-someone-please-check-my-scripting-for-php/29113/3 "2003-08-22T21:34:33Z")

</div>

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
<?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_

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [August 22, 2003, 10:05pm UTC](https://forum.kirupa.com/t/could-someone-please-check-my-scripting-for-php/29113/4 "2003-08-22T22:05:07Z")

</div>

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:

```php

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](http://www.kirupaforum.com/forums/showthread.php?s=&threadid=17604&highlight=PHP+tutorial)

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [August 23, 2003, 3:58am UTC](https://forum.kirupa.com/t/could-someone-please-check-my-scripting-for-php/29113/5 "2003-08-23T03:58:52Z")

</div>

which $email var are you talking about.

this one:  
1.

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

```

or this one:

1. 

```php
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.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [August 23, 2003, 5:10am UTC](https://forum.kirupa.com/t/could-someone-please-check-my-scripting-for-php/29113/6 "2003-08-23T05:10:05Z")

</div>

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

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

in otherwords

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

```

rather than what i had before

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

```

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [August 23, 2003, 8:49pm UTC](https://forum.kirupa.com/t/could-someone-please-check-my-scripting-for-php/29113/7 "2003-08-23T20:49:21Z")

</div>

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

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:

```php

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!! 😛

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [August 23, 2003, 10:28pm UTC](https://forum.kirupa.com/t/could-someone-please-check-my-scripting-for-php/29113/8 "2003-08-23T22:28:23Z")

</div>

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) !!

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [August 24, 2003, 10:16am UTC](https://forum.kirupa.com/t/could-someone-please-check-my-scripting-for-php/29113/9 "2003-08-24T10:16:08Z")

</div>

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