I am new to the world of PHP. Below is my simple PHP file "invite.php " with a form having an image send button (I have to use the image send button because it is the requirement, may be this is causing problem!):
[code=html]
<html>
<head><title>Fo rm</title>
</head>
<body>
<script language="javas cript" src="validation .js"></script>
<form action="submit. php" method="POST">
<table border ="0" align="center" cellpadding="9" cellspacing="1" >
<tr>
<td colspan="2">Ent er Your Friends' E-mail Addresses<br/>Separate multiple addresses with a comma<br/>
<textarea name="emails" id="emails" class="subheadi ng" value="" rows="5" cols="52" onfocus= "javascript :if (document.getEl ementById('emai ls').value=='') { document.getEle mentById('email s').value=''; }" onblur="javascr ipt:if (document.getEl ementById('emai ls').value=='') { document.getEle mentById('email s').value=''; }"></textarea>
</td>
</tr>
<tr>
<td>Meeting Date<br/>
<input type="text" name="inputDate " id="inputDate" class="subheadi ng" value="" maxlength="17" size="32" onfocus= "javascript :if (document.getEl ementById('inpu tDate').value== '') { document.getEle mentById('input Date').value='' ; }" onblur="javascr ipt:if (document.getEl ementById('inpu tDate').value== '') { document.getEle mentById('input Date').value='' ; }" /> <img src="calendar.g if" alt="Calendar" name="calendar" width="14" height="14" id="calendar" />
</td>
<td>Meeting Time<br/>
<input type="text" name="meettime" id="meettime" class="subheadi ng" value=" Noon to Midnight" maxlength="36" size="36" onfocus= "javascript :if (document.getEl ementById('meet time').value==' Noon to Midnight') { document.getEle mentById('meett ime').value=''; }" onblur="javascr ipt:if (document.getEl ementById('meet time').value==' ') { document.getEle mentById('meett ime').value=' Noon to Midnight'; }" />
</td>
</tr>
<tr>
<td>Your Name<br/>
<input type="text" name="vname" id="vname" class="subheadi ng" value=" Your Name" maxlength="36" size="36" onfocus= "javascript :if (document.getEl ementById('vnam e').value==' Your Name') { document.getEle mentById('vname ').value=''; }" onblur="javascr ipt:if (document.getEl ementById('vnam e').value=='') { document.getEle mentById('vname ').value=' Your Name'; }" />
</td>
<td>Your E-mail Address<br/>
<input type="text" name="visitorma il" id="visitormail " class="subheadi ng" value=" Your E-Mail Address" maxlength="36" size="36" onfocus= "javascript :if (document.getEl ementById('visi tormail').value ==' Your E-Mail Address') { document.getEle mentById('visit ormail').value= ''; }" onblur="javascr ipt:if (document.getEl ementById('visi tormail').value =='') { document.getEle mentById('visit ormail').value= ' Your E-Mail Address'; }" />
</td>
</tr>
<tr>
<td colspan="2">Opt ional Message<br/>
<textarea name="message" id="message" class="subheadi ng" value="" rows="5" cols="52" onfocus= "javascript :if (document.getEl ementById('mess age').value=='' ) { document.getEle mentById('messa ge').value=''; }" onblur="javascr ipt:if (document.getEl ementById('mess age').value=='' ) { document.getEle mentById('messa ge').value=''; }"></textarea>
<p align="left"><i nput type="image" src="send.gif" name="send" alt="Send" value="Send" onclick="fValid ateContact(this .form); return false;" /></p>
</td>
</tr>
</table>
</form>
</body>
</html>
The file mentioned in (action="submit .php") is as under:
<html>
<head><title>Su ccess Message</title>
</head>
<body>
<?php
$inputDate = $HTTP_POST_VARS['inputDate'];
$meettime = $HTTP_POST_VARS['meettime'];
$visitormail = $_POST['visitormail'];
?>
<table border ="0" align="center" cellpadding="9" >
<tr>
<td align="center"> <p align="center"> Success! Your Data has been processed by PHP. Details are: <br />
Your Email address was: <?php echo $visitormail; ?><br />
Meeting Date was : <?php echo $inputDate ?><br />
Meeting Time was : <?php echo $meettime ?><br /></p>
</td>
</tr>
</table>
</body>
</html>
Finally "validation .js" is as under:
function fValidateContac t(form)
{
if(form.emails. value == '')
{
alert("Please enter Your Friend's Email to proceed."); form.emails.foc us();
}
else if((form.emails .value.indexOf( ".") == -1) || (form.emails.va lue.indexOf("@" ) == -1))
{
alert("Please enter a valid Friend's Email."); form.emails.foc us();
}
else if(form.inputDa te.value == '')
{
alert("Please choose Meeting Date from the Calendar."); form.inputDate. focus();
}
else if(form.meettim e.value == '')
{
alert("Please enter Meeting Time to proceed."); form.meettime.f ocus();
}
else if(form.vname.v alue == '')
{
alert("Please enter Your Name to proceed."); form.vname.focu s();
}
else if(form.visitor mail.value == '')
{
alert("Please enter Email Address to proceed."); form.visitormai l.focus();
}
else if((form.visito rmail.value.ind exOf(".") == -1) || (form.visitorma il.value.indexO f("@") == -1))
{
alert("Please enter a valid Email Address."); form.visitormai l.focus();
}
else
form.submit(); //May be this is the mistake? But what should I do then?
}[/code]
[Please use CODE tags when posting source code. Thanks! --pbmods]
I don't understand why PHP is not processing the data provided especially:
$visitormail = $_POST['visitormail'];
Please help me out. Thanks.
[code=html]
<html>
<head><title>Fo rm</title>
</head>
<body>
<script language="javas cript" src="validation .js"></script>
<form action="submit. php" method="POST">
<table border ="0" align="center" cellpadding="9" cellspacing="1" >
<tr>
<td colspan="2">Ent er Your Friends' E-mail Addresses<br/>Separate multiple addresses with a comma<br/>
<textarea name="emails" id="emails" class="subheadi ng" value="" rows="5" cols="52" onfocus= "javascript :if (document.getEl ementById('emai ls').value=='') { document.getEle mentById('email s').value=''; }" onblur="javascr ipt:if (document.getEl ementById('emai ls').value=='') { document.getEle mentById('email s').value=''; }"></textarea>
</td>
</tr>
<tr>
<td>Meeting Date<br/>
<input type="text" name="inputDate " id="inputDate" class="subheadi ng" value="" maxlength="17" size="32" onfocus= "javascript :if (document.getEl ementById('inpu tDate').value== '') { document.getEle mentById('input Date').value='' ; }" onblur="javascr ipt:if (document.getEl ementById('inpu tDate').value== '') { document.getEle mentById('input Date').value='' ; }" /> <img src="calendar.g if" alt="Calendar" name="calendar" width="14" height="14" id="calendar" />
</td>
<td>Meeting Time<br/>
<input type="text" name="meettime" id="meettime" class="subheadi ng" value=" Noon to Midnight" maxlength="36" size="36" onfocus= "javascript :if (document.getEl ementById('meet time').value==' Noon to Midnight') { document.getEle mentById('meett ime').value=''; }" onblur="javascr ipt:if (document.getEl ementById('meet time').value==' ') { document.getEle mentById('meett ime').value=' Noon to Midnight'; }" />
</td>
</tr>
<tr>
<td>Your Name<br/>
<input type="text" name="vname" id="vname" class="subheadi ng" value=" Your Name" maxlength="36" size="36" onfocus= "javascript :if (document.getEl ementById('vnam e').value==' Your Name') { document.getEle mentById('vname ').value=''; }" onblur="javascr ipt:if (document.getEl ementById('vnam e').value=='') { document.getEle mentById('vname ').value=' Your Name'; }" />
</td>
<td>Your E-mail Address<br/>
<input type="text" name="visitorma il" id="visitormail " class="subheadi ng" value=" Your E-Mail Address" maxlength="36" size="36" onfocus= "javascript :if (document.getEl ementById('visi tormail').value ==' Your E-Mail Address') { document.getEle mentById('visit ormail').value= ''; }" onblur="javascr ipt:if (document.getEl ementById('visi tormail').value =='') { document.getEle mentById('visit ormail').value= ' Your E-Mail Address'; }" />
</td>
</tr>
<tr>
<td colspan="2">Opt ional Message<br/>
<textarea name="message" id="message" class="subheadi ng" value="" rows="5" cols="52" onfocus= "javascript :if (document.getEl ementById('mess age').value=='' ) { document.getEle mentById('messa ge').value=''; }" onblur="javascr ipt:if (document.getEl ementById('mess age').value=='' ) { document.getEle mentById('messa ge').value=''; }"></textarea>
<p align="left"><i nput type="image" src="send.gif" name="send" alt="Send" value="Send" onclick="fValid ateContact(this .form); return false;" /></p>
</td>
</tr>
</table>
</form>
</body>
</html>
The file mentioned in (action="submit .php") is as under:
<html>
<head><title>Su ccess Message</title>
</head>
<body>
<?php
$inputDate = $HTTP_POST_VARS['inputDate'];
$meettime = $HTTP_POST_VARS['meettime'];
$visitormail = $_POST['visitormail'];
?>
<table border ="0" align="center" cellpadding="9" >
<tr>
<td align="center"> <p align="center"> Success! Your Data has been processed by PHP. Details are: <br />
Your Email address was: <?php echo $visitormail; ?><br />
Meeting Date was : <?php echo $inputDate ?><br />
Meeting Time was : <?php echo $meettime ?><br /></p>
</td>
</tr>
</table>
</body>
</html>
Finally "validation .js" is as under:
function fValidateContac t(form)
{
if(form.emails. value == '')
{
alert("Please enter Your Friend's Email to proceed."); form.emails.foc us();
}
else if((form.emails .value.indexOf( ".") == -1) || (form.emails.va lue.indexOf("@" ) == -1))
{
alert("Please enter a valid Friend's Email."); form.emails.foc us();
}
else if(form.inputDa te.value == '')
{
alert("Please choose Meeting Date from the Calendar."); form.inputDate. focus();
}
else if(form.meettim e.value == '')
{
alert("Please enter Meeting Time to proceed."); form.meettime.f ocus();
}
else if(form.vname.v alue == '')
{
alert("Please enter Your Name to proceed."); form.vname.focu s();
}
else if(form.visitor mail.value == '')
{
alert("Please enter Email Address to proceed."); form.visitormai l.focus();
}
else if((form.visito rmail.value.ind exOf(".") == -1) || (form.visitorma il.value.indexO f("@") == -1))
{
alert("Please enter a valid Email Address."); form.visitormai l.focus();
}
else
form.submit(); //May be this is the mistake? But what should I do then?
}[/code]
[Please use CODE tags when posting source code. Thanks! --pbmods]
I don't understand why PHP is not processing the data provided especially:
$visitormail = $_POST['visitormail'];
Please help me out. Thanks.
Comment