473,753 Members | 8,053 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Facing problems with $_POST. Data can not be processed by PHP...

9 New Member
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!):

Expand|Select|Wrap|Line Numbers
  1. <html>
  2.  <head><title>Form</title>
  3.  </head>
  4.  <body>
  5.   <script language="javascript" src="validation.js"></script>
  6.    <form action="submit.php" method="POST"> 
  7.     <table border ="0" align="center" cellpadding="9" cellspacing="1">          
  8.      <tr>
  9.       <td colspan="2">Enter Your Friends' E-mail Addresses<br/>Separate multiple addresses with a comma<br/>
  10.        <textarea name="emails" id="emails" class="subheading" value="" rows="5" cols="52" onfocus= "javascript:if (document.getElementById('emails').value=='') { document.getElementById('emails').value=''; }" onblur="javascript:if (document.getElementById('emails').value=='') { document.getElementById('emails').value=''; }"></textarea>
  11.       </td>
  12.      </tr>
  13.      <tr>
  14.       <td>Meeting Date<br/>
  15.        <input type="text" name="inputDate" id="inputDate" class="subheading" value="" maxlength="17" size="32" onfocus= "javascript:if (document.getElementById('inputDate').value=='') { document.getElementById('inputDate').value=''; }" onblur="javascript:if (document.getElementById('inputDate').value=='') { document.getElementById('inputDate').value=''; }" />&nbsp;<img src="calendar.gif" alt="Calendar" name="calendar" width="14" height="14" id="calendar" />
  16.       </td>                                                                        
  17.       <td>Meeting Time<br/>
  18.        <input type="text" name="meettime" id="meettime" class="subheading" value=" Noon to Midnight" maxlength="36" size="36" onfocus= "javascript:if (document.getElementById('meettime').value==' Noon to Midnight') { document.getElementById('meettime').value=''; }" onblur="javascript:if (document.getElementById('meettime').value=='') { document.getElementById('meettime').value=' Noon to Midnight'; }" />
  19.       </td>
  20.      </tr>
  21.      <tr>
  22.       <td>Your Name<br/>
  23.        <input type="text" name="vname" id="vname" class="subheading" value=" Your Name" maxlength="36" size="36" onfocus= "javascript:if (document.getElementById('vname').value==' Your Name') { document.getElementById('vname').value=''; }" onblur="javascript:if (document.getElementById('vname').value=='') { document.getElementById('vname').value=' Your Name'; }" />
  24.       </td>
  25.       <td>Your E-mail Address<br/>
  26.        <input type="text" name="visitormail" id="visitormail" class="subheading" value=" Your E-Mail Address" maxlength="36" size="36" onfocus= "javascript:if (document.getElementById('visitormail').value==' Your E-Mail Address') { document.getElementById('visitormail').value=''; }" onblur="javascript:if (document.getElementById('visitormail').value=='') { document.getElementById('visitormail').value=' Your E-Mail Address'; }" /> 
  27.       </td>
  28.      </tr>
  29.      <tr>
  30.       <td colspan="2">Optional Message<br/>
  31.        <textarea name="message" id="message" class="subheading" value="" rows="5" cols="52" onfocus= "javascript:if (document.getElementById('message').value=='') { document.getElementById('message').value=''; }" onblur="javascript:if (document.getElementById('message').value=='') { document.getElementById('message').value=''; }"></textarea>
  32.         <p align="left"><input type="image" src="send.gif" name="send" alt="Send" value="Send" onclick="fValidateContact(this.form); return false;"  /></p> 
  33.       </td>
  34.      </tr>
  35.     </table>
  36.    </form>
  37.  </body>
  38. </html>
  39.  
  40. The file mentioned in (action="submit.php") is as under:
  41.  
  42. <html>
  43.  <head><title>Success Message</title>
  44.  </head>
  45.  <body>
  46.   <?php
  47. $inputDate = $HTTP_POST_VARS['inputDate'];
  48. $meettime = $HTTP_POST_VARS['meettime'];
  49. $visitormail = $_POST['visitormail'];
  50.    ?>   
  51.   <table border ="0" align="center" cellpadding="9">          
  52.     <tr>
  53.      <td align="center"><p align="center">Success! Your Data has been processed by PHP. Details are: <br />
  54.      Your Email address was: <?php echo $visitormail; ?><br />
  55.      Meeting Date was : <?php echo $inputDate ?><br />
  56.      Meeting Time was : <?php echo $meettime ?><br /></p>
  57.      </td>
  58.     </tr>
  59.  </table> 
  60.  </body>
  61. </html>
  62.  
  63. Finally "validation.js" is as under:
  64.  
  65. function fValidateContact(form)
  66. {
  67.     if(form.emails.value == '')
  68.     {        
  69.             alert("Please enter Your Friend's Email to proceed."); form.emails.focus();
  70.     }
  71.     else if((form.emails.value.indexOf(".") == -1) || (form.emails.value.indexOf("@") == -1))
  72.     {
  73.          alert("Please enter a valid Friend's Email."); form.emails.focus();
  74.     }        
  75.     else if(form.inputDate.value == '')
  76.      {        
  77.  alert("Please choose Meeting Date from the Calendar."); form.inputDate.focus();
  78.      }
  79.     else if(form.meettime.value == '')
  80.      {
  81.  alert("Please enter Meeting Time to proceed."); form.meettime.focus();
  82.      }
  83.     else if(form.vname.value == '')
  84.     {
  85. alert("Please enter Your Name to proceed."); form.vname.focus();
  86.     }
  87.     else if(form.visitormail.value == '')
  88.     {
  89.  alert("Please enter Email Address to proceed."); form.visitormail.focus();
  90.     }
  91.     else if((form.visitormail.value.indexOf(".") == -1) || (form.visitormail.value.indexOf("@") == -1))
  92.     {
  93. alert("Please enter a valid Email Address."); form.visitormail.focus();
  94.     }
  95.     else
  96.     form.submit(); //May be this is the mistake? But what should I do then?
  97. }
[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.
Jun 13 '07 #1
10 2758
Anthony2oo5
26 New Member
Can you simplify your code for us and also explain what is the problem more.
Jun 13 '07 #2
epots9
1,351 Recognized Expert Top Contributor
give your form a name/id:
[HTML]<form action="submit. php" method="POST" name="form1" id="form1"> [/HTML]
try instead of passing this.form, pass nothing and in the function do:
Expand|Select|Wrap|Line Numbers
  1. var form = document.form1;
Jun 13 '07 #3
Purple
404 Recognized Expert Contributor
Hi all,

I have done a couple of tweeks to the php in this code follows:

[PHP]
<?php
if (isset($_POST['inputDate'])) $inputDate = $_POST['inputDate']; else $inputDate = null;
if (isset($_POST['meettime'])) $meettime = $_POST['meettime']; else $meettime = null;
if (isset($_POST['visitormail'])) $visitormail = $_POST['visitormail']; else $visitormail = null;
?>
[/PHP]

will fix the error messages on the first run, when I tested it the javascript validation worked ok

try these sugestions and post back if you are still having problems with a bit more of an explanation of your issue..

Regards Purple
Jun 13 '07 #4
sufian
9 New Member
Hi all,
Thanks for your kind reply. I am still facing the same problems!
I have given a name and id to the form in invite.php and moreover follows the second advice regarding Javascript, but the issue is not resolved. Furthermore the code provided by Purple could not resolved the issue. I have also tried the following code in submit.php

Expand|Select|Wrap|Line Numbers
  1. <?php 
  2.  print_r ($_POST); 
  3. ?>
But its not working indicating that this file is not receiving POST variables.

Here is the problem in more detail:
When I click the Submit button the submit.php file only displays the text but no data which was inserted on the form of the previous php file (invite.php). If data could not be processed by PHP then how come I send an auto mail reply to the visitor of this form (which is yet another requirement to be fulfilled)? Because as far as my limited knowledge the mail function in php takes the recepient email as its first argument.
Actually this page would be part of a coffee shop website (www.t2f.biz) made on Word Press and someone who wants to meet his/her friends at the coffee shop at a specified time and date will enter the details here and would get an auto mail reply with the following message:
Sabeen Mahmud has invited you to meet up at The Second Floor on <the date selected from calendar> at <the time inserted in the text field>

and the stuff like that.
Jun 14 '07 #5
Purple
404 Recognized Expert Contributor
Hi,

Can you post the code as it is now into this - please can you wrap it in php code tags by highlighting the code after it has been inserted and pressing the php button on the right of the menu above.

Purple
Jun 14 '07 #6
Purple
404 Recognized Expert Contributor
Hi,

I have setup and run your forms based on the changes I suggested and follow is the output, note the array is the output of a print_r($_POST) :

Expand|Select|Wrap|Line Numbers
  1. Array ( [emails] => my@email.address [inputDate] => 20/20/20 [meettime] => Noon to Midnight [vname] => adam [visitormail] => me@mine.com [message] => optional message ) 
  2.  
  3. Success! Your Data has been processed by PHP. 
  4. Details are: 
  5. Your Email address was: me@mine.com
  6. Meeting Date was : 20/20/20
  7. Meeting Time was : Noon to Midnight
your code with a couple of changes is as follows:

invite.php:

[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='' ; }" />&nbsp;<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>[/HTML]

submit.php

[PHP]<html><head><ti tle>Success Message</title></head><body>
<?php
print_r($_POST) ;
if (isset($_POST['inputDate'])) $inputDate = $_POST['inputDate']; else $inputDate = null;
if (isset($_POST['meettime'])) $meettime = $_POST['meettime']; else $meettime = null;
if (isset($_POST['visitormail'])) $visitormail = $_POST['visitormail']; else $visitormail = null;
?>
<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> [/PHP]

and finally validation.js:

Expand|Select|Wrap|Line Numbers
  1. function fValidateContact(form)
  2. {
  3. if(form.emails.value == '')
  4. {
  5. alert("Please enter Your Friend's Email to proceed."); form.emails.focus();
  6. }
  7. else if((form.emails.value.indexOf(".") == -1) || (form.emails.value.indexOf("@") == -1))
  8. {
  9. alert("Please enter a valid Friend's Email."); form.emails.focus();
  10. }
  11. else if(form.inputDate.value == '')
  12. {
  13. alert("Please choose Meeting Date from the Calendar."); form.inputDate.focus();
  14. }
  15. else if(form.meettime.value == '')
  16. {
  17. alert("Please enter Meeting Time to proceed."); form.meettime.focus();
  18. }
  19. else if(form.vname.value == '')
  20. {
  21. alert("Please enter Your Name to proceed."); form.vname.focus();
  22. }
  23. else if(form.visitormail.value == '')
  24. {
  25. alert("Please enter Email Address to proceed."); form.visitormail.focus();
  26. }
  27. else if((form.visitormail.value.indexOf(".") == -1) || (form.visitormail.value.indexOf("@") == -1))
  28. {
  29. alert("Please enter a valid Email Address."); form.visitormail.focus();
  30. }
  31. else
  32. form.submit(); //May be this is the mistake? But what should I do then?
  33. }
I suggest you copy my three code blocks and run them as posted and see it that works for you - you can see from the output of the submit.php and print_r($_POST) that all of the form variables I entered in invite.php have been carried through to submit.php.

All of that said, I may be completely missing the point here - if that is the case just say so and have another go at telling me the problem

Regards Purple
Jun 14 '07 #7
sufian
9 New Member
Hi,
Thanks for your quick reply.
Actually I am working in a Network environment (LAN of the company) where PHP is installed only on a server not on my PC. A drive of that server was mapped on my PC when I have given this PC on the first day of my job a few days ago. When given this task I have created a new folder in that mapped drive and start coding PHP. In this mapped drive all of the company's web applications folders are already kept and all applications are working properly from browser on my PC (those application ofcourse contain some PHP code which is functional). Therefore I thought since PHP is working fine at that server, it will also work when I will write code!
I guess this mapped network drive is causing problem because when I have tested the following simple code at M:\Sufian\Proje cts\Self Testing for PHP
where M is the network mapped drive of the server.

[PHP]<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dt d">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Web Forms in PHP</title>
</head>
<body>
<h1>Web Forms in PHP</h1>
<form action="guest.p hp" method="post">
<table border="0">
<tr><td>Your Name:</td>
<td><input type="text" maxlength="32" size="20" name="user" /></td></tr>
<tr><td>Your Email Address:</td>
<td><input type="text" maxlength="32" size="20" name="mail" /></td></tr>
<tr><td><inpu t type="submit" value="Submit Deatils" /></td>
<td><input type="reset" value="Reset The Form" /></td></tr>
</table>
</form>
</body>
</html>
[/PHP]

guest.php is as under:

[PHP]<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dt d">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Your Data</title>
</head>
<body>
<h1>Your Data Processes By PHP</h1>
<table border="0">
<tr><th>Your Name:</th><td><?php echo $_POST['user']; ?></td></tr>
<tr><th>Your Email Address:</th><td><?php echo $_POST['mail']; ?></td></tr></table>
</body>
</html>
[/PHP]

Then PHP code is not working.
When I have discussed this problem with a senior colleague, he is saying we have been working for seven years like that and PHP should work like that. Can you please comment on it?
The solution that I am thinking now is to install PHP latest version on my PC and then try to complete my task.
Last but not the least I am from the bottom of my heart really grateful for your kind responses.
May Allah bless you.
Jun 14 '07 #8
Purple
404 Recognized Expert Contributor
Hi,

try this code:

[PHP]<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>New document</title>
</head>
<body>
php info follows<br/>
<?php phpinfo();?>
php info preceeds<br/>
</body>
</html>[/PHP]

and let me know if you get a page full of info on your PHP installation config

Regards Purple
Jun 14 '07 #9
sufian
9 New Member
PHP was not working from:
M:\Sufian\Proje cts\Self Testing for PHP
But it is working from:
M:\t2fv2\Sufian \Projects\Self Testing for PHP
Where t2fv2 is the name of one of the application installed at that mapped drive.
I get the page full of info of my PHP installation config from there. Now I have also tried the code provided by you and its working!!!!!!!! !!!!!!!!!!!!!
Thanks a lot.
Jun 14 '07 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

0
1899
by: Ralf Hornbeck | last post by:
Hi, I have just uploaded an older PHP project I have written by myself up to my new webserver. On this server PHP is running in version 4.3.2 and this seems to result in some trouble, since the project worked out pretty fine some weeks ago under PHP 4.2.3 (I think). My suggestion is that it has to do sth. with sessionhandling, but I am not sure. I don't think that the DB connection is responsible for the problems and I
9
6792
by: Quinonez | last post by:
if i set a $_SESSION=$_POST in every page of a multiple page form how then would i call it on a later page of the same session? and also how is distigushed between pages ? should it be set up differently on each page, ive read of $_SESSION=$_POST but i cant seem to figure out how to call it back at the end of the form
3
43947
by: Robert Oschler | last post by:
I know there isn't any $_POST array in Javascript, it exists on the server side accessible from PHP and other server side scripting languages. But I knew it would let you know specifically what data I'm after. Is there any way to get the data that is POSTED to a web page from client-side Javascript? Or does only the server get access to it? I can get access to the URL/href data from the "search" property, but that's because it's part...
24
2882
by: moriman | last post by:
Hi, The script below *used* to work. I have only just set up a server, PHP etc again on my Win98 system and now it doesn't? On first loading this page, you would have $p = and the button image below it.
16
2537
by: pamelafluente | last post by:
I am still working with no success on that client/server problem. I need your help. I will submit simplified versions of my problem so we can see clearly what is going on. My model: A client uses IE to talk with a server. The user on the client (IE) sees an ASP net page containing a TextBox. He can write some text in this text box and push a submit button.
2
1948
by: Cerebral Believer | last post by:
Hi folks, Can anyone help me with this form: http://futurebydesign-music.com/_member/club_fbd_reg.php I have followed to coding instructions aas closely as I can, but I am getting errors about not filling in all the fields on the form correctly when I test it. Is validating a form with radio buttons difficult?
1
1419
by: Nosferatum | last post by:
I intend to upload documents (file_up), categorize them in 4 main categories (k_cat), have additional sub-categories (lec_cat) just for querying and getting sub-categorized output of the files when listed with date (dato_inn) and the submitters details "uploaded_by". But my script will not work. Anyone clever out there seeing what's wrong? This is my upload form, the script at the bottom:
6
2179
by: fpcreator2000 | last post by:
Hello everyone. I'm having problems with a page I've created that is used to insert data into a database. It uploads two files into two distinct folder, and it takes the filenames and inserts them into a MYSQL database along with other product information. Here is the entire .php file. I list it because the errors are not showing at all, and I need a fresh pair of eyes to look at it. Any answers, critisims (constructive), or other talk...
3
3555
by: arggg | last post by:
I have a form in PHP that needs to be processed by the same page. I have ajax calling the page and parsing the data however I cannot get the POST data to be sent via AJAX to the PHP Page. I found this site which gives me an idea that you need to setup the $_POST methods as what looks like a GET then you send the information to the PHP page which in turn interprets it as $_POST data. However I was wondering is there a way that without me...
0
9072
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9653
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9451
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9333
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6151
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4771
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4942
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3395
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2872
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.