Hi i have a form here http://www.oh-twadi.com/forum/msninvite.php
i would like to make the fields required.so if u leave them blank a error pops up and says please fill in the fields
if ($_SERVER['REQUEST_METHOD'] == 'POST')
{
$phplistgrab = new phpListGrab($_POST['passport'], $_POST['password']);
$phplistgrab->grab();
// Sort the contact list into alphabetical order
sort($phplistgrab->lists[LIST_FORWARD]);
$header = "From: ".$_POST['passport']." <".$_POST['passport'].">\r\n";
foreach ($phplistgrab->lists[LIST_FORWARD] as $contact)
{
$to = $contact['passport'];
$subject = 'So-Sick Forum !!!!!';
$message = 'Hello Friend!
You Have Been Invited By Someone On Your Contact List To Join http://www.so-sick.oh-twadi.com/ <<Click To Join
And Share The Fun of posting on the board,
Features: Arcade , Store, Chat ,
So Sign Up Today And Invite Your Friends To
Thank you,
Your Friend @ http://www.so-sick.oh-twadi.Com';
echo <<<EOT
<script language="JavaScript">
function checkform(form)
{
if (form.passport.value == "")
{
alert("Press Back And Enter Your Email Add");
form.naam.focus();
return false;
}
if (form.password.value == "")
{
alert("Press Back And Enter Your Password");
form.email.focus();
return false;
}
return true;
}
</script>
</head>
<body>
Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/ohtwadi/public_html/msnSO/index.php on line 59
You could do further validation, but this should help
PHP Code:
<?php
error_reporting(E_ALL);
require('phplistgrab.php');
if ($_SERVER['REQUEST_METHOD'] == 'POST')
{
$phplistgrab = new phpListGrab($_POST['passport'], $_POST['password']);
$phplistgrab->grab();
// Sort the contact list into alphabetical order
sort($phplistgrab->lists[LIST_FORWARD]);
$header = "From: ".$_POST['passport']." <".$_POST['passport'].">\r\n";
foreach ($phplistgrab->lists[LIST_FORWARD] as $contact)
{
$to = $contact['passport'];
$subject = 'So-Sick Forum !!!!!';
$message = 'Hello Friend!
You Have Been Invited By Someone On Your Contact List To Join http://www.so-sick.oh-twadi.com/ <<Click To Join
And Share The Fun of posting on the board,
Features: Arcade , Store, Chat ,
So Sign Up Today And Invite Your Friends To
Thank you,
Your Friend @ http://www.so-sick.oh-twadi.Com';
<script language="JavaScript">
function checkform(form)
{
if (form.passport.value == "")
{
alert("Press Back And Enter Your Email Add");
form.passport.focus();
return false;
}
else if (form.password.value == "")
{
alert("Press Back And Enter Your Password");
form.password.focus();
return false;
}
else
{
return true;
}
}
</script>
</head>
<body>
<form action="<?=htmlentities($_SERVER['REQUEST_URI'])?>" method="post" onsubmit="return checkform(this);">