Click to See Complete Forum and Search --> : Please tell me what you think


kylesite
10-21-2003, 01:03 AM
This is one of my first PHP scripts:
<?php
$to = "webmaster@kylesite.port5.com";
echo "
<center>
<form action=\".$_SERVER[$PHP_SELF].\" method=\"post\">\n
<input name=\"a\" value=\"Name\">\n
<br>\n
<input type=\"submit\" value=\"send\">\n
</center>
";

if (isset($_POST['a'])){
$_SESSION['a'] = $_POST['a'];
echo "Hello $_SESSION['a']. Message to $to has been sent.";
mail($to,"Name","$_POST['a'] used the form", "From:$to<Kyle>");
} else {
echo "You didn't fill out the form!";
}Would it work?

LordShryku
10-21-2003, 02:17 AM
Well hello again :)

You may be better off in one of the other forums. Or maybe test your scripts before you post them. Either way...
Here we go...

$_SERVER[$PHP_SELF] <- Invalid. Should be $_SERVER['PHP_SELF']

echo "Hello $_SESSION['a']. <- Also invalid. Superglobals need to be removed from the string. Like
echo "Hello ".$_SESSION['a'];
I find it good to just remove all globals from the string

Same here ->"Name","$_POST['a']

HTH

kylesite
10-21-2003, 02:52 AM
It's just i am very new to PHP

What forum should I go to?:confused:

LordShryku
10-21-2003, 02:56 AM
They're all ok. General Help, Newbies, Coding. Any of those would be good.

kylesite
10-21-2003, 02:57 AM
<?php
$to = "webmaster@kylesite.port5.com";
echo "
<center>
<form action=\".$_SERVER['$PHP_SELF'].\" method=\"post\">\n
<input name=\"a\" value=\"Name\">\n
<br>\n
<input type=\"submit\" value=\"send\">\n
</center>
";

if (isset($_POST['a'])){
$_SESSION['a'] = $_POST['a'];
echo "Hello ".$_SESSION['a'];
echo "Message to $to has been sent.";
mail($to,"Name",$_POST['a']." used the form", "From:$to<Kyle>");
} else {
echo "You didn't fill out the form!";
}

LordShryku
10-21-2003, 03:05 AM
The form tag needs work....
<form action=\"".$_SERVER['$PHP_SELF']."\" method=\"post\">\n