How to POST the data to second page?

Reply

Join Date: Apr 2008
Posts: 29
Reputation: kira4 is an unknown quantity at this point 
Solved Threads: 0
kira4 kira4 is offline Offline
Light Poster

How to POST the data to second page?

 
-1
  #1
Oct 5th, 2009
This is the first page of my website(AssociationAdd.php). When I clicked the 'Add' button, it shows that :
"Notice: Undefined index: T2 in c:\easyphp1-8\www\efiling\associationaddprocess.php on line 19

Notice: Undefined index: T1 in c:\easyphp1-8\www\efiling\associationaddprocess.php on line 20"

  1. <html>
  2. <head>
  3. <meta http-equiv="Content-Language" content="ja">
  4. <title>Index</title>
  5. </head>
  6. <div style="position: absolute; width: 1146px; height: 842px; z-index: 1; left:10px; top:1px" id="layer2" align="center">
  7.  
  8. <body background="E-Filing%20Management%20System%20Picture/Snow.gif">
  9.  
  10. <p align="center">
  11. <img border="0" src="E-Filing%20Management%20System%20Picture/logo-RR-gif.gif" width="957" height="245"></p>
  12. <p align="center"><span lang="zh-cn">&nbsp;</span></p>
  13. <p align="center"><span lang="zh-cn"><img border="0" src="E-Filing%20Management%20System%20Picture/Association.gif" width="491" height="74"></span></p>
  14.  
  15. <p align="center"><span lang="zh-cn">&nbsp;</span></p>
  16. <div style="position: absolute; width: 191px; height: 28px; z-index: 2; left: 546px; top: 441px" id="layer4">
  17. <font color="#FFFFFF"><span lang="en-us">
  18.  
  19.  
  20. <font size="4" face="Arial Rounded MT Bold">&nbsp;Association Name</font></span></font></div>
  21. <div style="position: absolute; width: 70px; height: 24px; z-index: 1; left: 298px; top: 442px" id="layer3">
  22. <font size="4" face="Arial Rounded MT Bold"><font color="#FFFFFF"><span lang="en-us">
  23.  
  24.  
  25. Index</span></font></font></div>
  26. <p align="center"><span lang="zh-cn">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  27. </span><font color="#FFFFFF"><span lang="en-us">
  28.  
  29.  
  30. <font face="Arial Rounded MT Bold">&nbsp;&nbsp;&nbsp;&nbsp;&nbs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p;&nbsp;&nbsp;&nbsp; &nbsp;</font></span></font></p>
  32. <p align="center"><span lang="en-us">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>
  33.  
  34. <?php
  35.  
  36. echo"<form method='POST' action='AssociationAdd.php'>";
  37. echo"<input type='text' name='T2' size='11'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
  38. echo"<input type='text' name='T1' size='77'></p>";
  39. echo"<p>&nbsp;<input type='submit' value=' Add ' name='submit' style='font-family: Times New Roman; color: #000000; font-weight: bold; font-size: 12pt'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
  40. echo"<input type='reset' value=' Reset ' name='B2' style='font-family: Times New Roman; color: #000000; font-weight: bold; font-size: 12pt'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
  41. echo"<input type='submit' value=' Back ' name='submit' style='font-family: Times New Roman; color: #000000; font-weight: bold; font-size: 12pt'></p>";
  42.  
  43.  
  44.  
  45. if(isset($_POST["submit"]))
  46. {
  47. $submit = $_POST["submit"];
  48. $T1 = $_POST["T1"];
  49. $T2= $_POST["T2"];
  50. if($submit==" Add ")
  51. {
  52. print "<script language ='javascript'>window.location.href='AssociationAddProcess.php?T1=$T1&T2=$T2'</script>";
  53. }
  54.  
  55. else if($submit==" Back ")
  56. {
  57. print "<script language ='javascript'>window.location.href='Association.php'</script>";
  58. }
  59. }
  60. echo"</form>";
  61. ?>
  62. </div>
  63. </body>
  64.  
  65. </html>

This is the second page(AssociationAddProcess.php):

  1. <html>
  2. <head>
  3. <meta http-equiv="Content-Language" content="ja">
  4. <title>Index</title>
  5. </head>
  6. <body background="E-Filing%20Management%20System%20Picture/Snow.gif">
  7.  
  8. <p align="center">
  9. <img border="0" src="E-Filing%20Management%20System%20Picture/logo-RR-gif.gif" width="957" height="245"></p>
  10. <p align="center"><span lang="zh-cn">&nbsp;</span></p>
  11. <p align="center"><span lang="zh-cn"><img border="0" src="E-Filing%20Management%20System%20Picture/Association.gif" width="491" height="74"></span></p>
  12.  
  13. <?php
  14.  
  15. $id = $_POST["T2"];
  16. $an = $_POST["T1"];
  17.  
  18. if ($id==null||$an==null)
  19. {
  20. print"
  21. <p align='center'>&nbsp;</p>
  22.  
  23. <table width='400' height='200' border='1' align='center' bordercolor='#66FF00'bgcolor='#0000FF'>
  24.  
  25. <td><div align='center'><font color='#FF0000' size='5'><p>Please Enter Index and Association Name Completely</p> </font></div></td>
  26. </tr>
  27. </table></td>
  28. </tr>
  29. </table></td>
  30. </tr>
  31. </table></td>
  32. </tr>
  33. </table> ";
  34.  
  35. print "<p align='center'>&nbsp;</p>";
  36. echo "<HTML><META HTTP-EQUIV='REFRESH' CONTENT='2; URL=AssociationAdd.php'>
  37. <CENTER><p>&nbsp;</p><p>&nbsp;
  38. <tr>
  39. <td align='center'><h12>please wait...</h12></td>
  40. </tr>
  41. </table><p>&nbsp;</p><p>&nbsp;</p></CENTER></BODY></HTML>";
  42. }
  43.  
  44. else
  45. {
  46. $connection=mysql_connect("localhost","root","")
  47. or die("<font color='#FFFFFF'>Could not connect to MySQL</font>".mysql_error());
  48.  
  49. $selection=mysql_select_db("efiling")
  50. or die("<font color='#FFFFFF'>Unable to select database.</font>".mysql_error());
  51.  
  52. $sql2 = "SELECT * from association Where AssociationName='$an'";
  53. $result2 = mysql_query($sql2)
  54. or die("<font color='#FFFFFF'>SQL select statement failed</font>");
  55.  
  56. if (mysql_num_rows($result2) < 1)
  57. {
  58. $sql = "INSERT INTO association(Index, AssociationName) VALUES ('$id', '$an')";
  59. $result=mysql_query($sql)
  60. or die("<font color='#FFFFFF'>SQL select statement failed</font>");
  61.  
  62. if ($result)
  63. {
  64. print "<script language ='javascript'>window.alert('Added Succesfully!');window.location.href='AssociationAdd.php'</script>";
  65. }
  66.  
  67. else
  68. {
  69. die(mysql_error());
  70. }
  71. }
  72. else
  73. {
  74. print"<p align='center'>&nbsp;</p>
  75. <table width='400' height='200' border='1' align='center' bordercolor='#66FF00'bgcolor='#0000FF'>
  76. <td><div align='center'><font color='#FF0000' size='5'><p>The Association Name Has Been Registered, Please Enter Other Association Name</p> </font></div></td>
  77. </tr>
  78. </table></td>
  79. </tr>
  80. </table></td>
  81. </tr>
  82. </table></td>
  83. </tr>
  84. </table> ";
  85.  
  86. print "<p align='center'>&nbsp;</p>";
  87. echo "<HTML><META HTTP-EQUIV='REFRESH' CONTENT='2; URL=AssociationAdd.php'>
  88. <CENTER><p>&nbsp;</p><p>&nbsp;
  89. <tr>
  90. <td align='center'><h12>please wait...</h12></td>
  91. </tr>
  92. </table><p>&nbsp;</p><p>&nbsp;</p></CENTER></BODY></HTML>";
  93.  
  94. }
  95. }
  96. ?>
  97.  
  98. </body>
  99. </html>

Anyone can tell me what is the problem and how to solve it?
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 3,739
Reputation: nav33n is a jewel in the rough nav33n is a jewel in the rough nav33n is a jewel in the rough 
Solved Threads: 330
Moderator
Featured Poster
nav33n's Avatar
nav33n nav33n is offline Offline
Senior Poster

Re: How to POST the data to second page?

 
-1
  #2
Oct 5th, 2009
Notices are not errors. If you try to use a variable without initializing it, you will get a notice. To disable notices, edit your php.ini and set error_reporting as,
error_reporting = E_ALL & ~E_NOTICE
This will show all the errors except notices.
But, if you want fix these notices, initialize every variable to null or 0 before using it.
Ignorance is definitely not bliss!

*PM asking for help will be ignored*
Reply With Quote Quick reply to this message  
Join Date: Apr 2008
Posts: 29
Reputation: kira4 is an unknown quantity at this point 
Solved Threads: 0
kira4 kira4 is offline Offline
Light Poster

Re: How to POST the data to second page?

 
0
  #3
Oct 5th, 2009
Originally Posted by nav33n View Post
Notices are not errors. If you try to use a variable without initializing it, you will get a notice. To disable notices, edit your php.ini and set error_reporting as,

This will show all the errors except notices.
But, if you want fix these notices, initialize every variable to null or 0 before using it.
changed already, still same.
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 3,739
Reputation: nav33n is a jewel in the rough nav33n is a jewel in the rough nav33n is a jewel in the rough 
Solved Threads: 330
Moderator
Featured Poster
nav33n's Avatar
nav33n nav33n is offline Offline
Senior Poster

Re: How to POST the data to second page?

 
-1
  #4
Oct 5th, 2009
What did you change ? php.ini or your script ?
If you are talking bout php.ini, did you restart your server ?
Ignorance is definitely not bliss!

*PM asking for help will be ignored*
Reply With Quote Quick reply to this message  
Join Date: Apr 2008
Posts: 29
Reputation: kira4 is an unknown quantity at this point 
Solved Threads: 0
kira4 kira4 is offline Offline
Light Poster

Re: How to POST the data to second page?

 
0
  #5
Oct 5th, 2009
Originally Posted by nav33n View Post
What did you change ? php.ini or your script ?
If you are talking bout php.ini, did you restart your server ?
Is that all of the error_reporting need to change to "error_reporting = E_ALL & ~E_NOTICE"?

Just now I didn't restart, now I restart already. It does not have the error already. But it still connect to "Please Enter Index and Association Name Completely" although I typed the index and name.

What does "error_reporting = E_ALL & ~E_NOTICE" means?
Last edited by kira4; Oct 5th, 2009 at 10:06 am.
Reply With Quote Quick reply to this message  
Join Date: Jun 2009
Posts: 44
Reputation: guru12 is an unknown quantity at this point 
Solved Threads: 6
guru12's Avatar
guru12 guru12 is offline Offline
Light Poster

Re: How to POST the data to second page?

 
0
  #6
Oct 5th, 2009
Hi

If you need the values from first page you should use the session for this implementation.
Reply With Quote Quick reply to this message  
Join Date: Apr 2008
Posts: 29
Reputation: kira4 is an unknown quantity at this point 
Solved Threads: 0
kira4 kira4 is offline Offline
Light Poster

Re: How to POST the data to second page?

 
0
  #7
Oct 5th, 2009
Originally Posted by guru12 View Post
Hi

If you need the values from first page you should use the session for this implementation.
But I don't know how to use session at all. >.<
using normal php cannot POST?
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 3,739
Reputation: nav33n is a jewel in the rough nav33n is a jewel in the rough nav33n is a jewel in the rough 
Solved Threads: 330
Moderator
Featured Poster
nav33n's Avatar
nav33n nav33n is offline Offline
Senior Poster

Re: How to POST the data to second page?

 
-1
  #8
Oct 5th, 2009
Originally Posted by kira4 View Post
Is that all of the error_reporting need to change to "error_reporting = E_ALL & ~E_NOTICE"?

Just now I didn't restart, now I restart already. It does not have the error already. But it still connect to "Please Enter Index and Association Name Completely" although I typed the index and name.
Since you aren't seeing the notices anymore, you have solved that problem. The other 'problem' you are talking about is a user defined error message. That simply means, you have written the logic wrong. I don't have enough time to go through your code, so I can only comment on it later.
What does "error_reporting = E_ALL & ~E_NOTICE" means?
This simply tells the php parser to report all the errors ~(negating or excluding) notices.
Ignorance is definitely not bliss!

*PM asking for help will be ignored*
Reply With Quote Quick reply to this message  
Join Date: Jul 2009
Posts: 178
Reputation: codejoust is an unknown quantity at this point 
Solved Threads: 17
codejoust's Avatar
codejoust codejoust is offline Offline
Junior Poster

Re: How to POST the data to second page?

 
1
  #9
Oct 5th, 2009
Also, it isn't necessary to echo out the forms...It's a lot easier to directly include them outside the PHP tags.
I'd also try to use better variable naming.
Why all the nonbreaking spaces? ( &nbsp; ).
If you REALLY need a space, try using CSS to provide that. ( <div style="width:200px; height:200px; position:relative"></div> )
It's also easier to redirect using head outputs, unless the form processing code isn't at the top of the document. I'd suggest putting the form processing code at the top, so you could simply do a header('Location: myloc.php'); .
You don't have to echo out code from if's, instead just close php like:
  1. <?php if ($submit == true){ ?>
  2. Thanks for you submission!
  3. <?php } else { ?>
  4. There were errors in your form.
  5. <?php } ?>
Or using keywords:
  1. <?php if ($submit == true): ?>
  2. Thanks for you submission!
  3. <?php endif; ?>
Most of this stuff makes the code easier to read, and less prone to blatant errors.
Last edited by codejoust; Oct 5th, 2009 at 1:34 pm. Reason: A similey was put in the code... forgot to add icode tags.
Reply With Quote Quick reply to this message  
Join Date: Apr 2008
Posts: 29
Reputation: kira4 is an unknown quantity at this point 
Solved Threads: 0
kira4 kira4 is offline Offline
Light Poster
 
0
  #10
Oct 7th, 2009
This problem was solved, thank for your help.
But now I am facing another problem, SQL select statement failed. Before that I can connect to database, is that any problem in my coding?
Reply With Quote Quick reply to this message  
Reply

Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC