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
 
0
  #11
Oct 7th, 2009
Sorry, network slow, causes double reply...
Last edited by kira4; Oct 7th, 2009 at 10:39 am.
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
 
0
  #12
Oct 7th, 2009
Originally Posted by kira4 View Post
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?
If you can clean up the code to the previous guidelines, and paste them here, I can take a better look at it.
Regarding the error, the statement looks ok..., however, I would select the database in the connect statement.
Make sure your connect variables are correct (you can echo them out before it connects to check), and the variable order is correct.
Is the connect or the query failing?
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
  #13
Oct 7th, 2009
Originally Posted by codejoust View Post
If you can clean up the code to the previous guidelines, and paste them here, I can take a better look at it.
Regarding the error, the statement looks ok..., however, I would select the database in the connect statement.
Make sure your connect variables are correct (you can echo them out before it connects to check), and the variable order is correct.
Is the connect or the query failing?
This is my "AssociationAdd.php" after solved the POST problem :

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

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

I tested by edit the echo already, the database error is here :

  1. if (mysql_num_rows($result2) < 1)
  2. {
  3. $sql = "INSERT INTO association(Index, AssociationName) VALUES ('$id', '$an')";
  4. $result=mysql_query($sql)
  5. or die("<font color='#FFFFFF'>SQL select statement failed</font>");

I think I don't have wrong spelling, this is print screen of my database :

http://img127.imageshack.us/img127/7750/association.jpg
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
  #14
Oct 7th, 2009
I was solved the problem.
Don't know why I can't use Index as my field in database, after I changed my field name then no problem already. Thanks for helping.
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 3,744
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
 
-1
  #15
Oct 7th, 2009
Originally Posted by kira4 View Post
I was solved the problem.
Don't know why I can't use Index as my field in database, after I changed my field name then no problem already. Thanks for helping.
FYI, index is a mysql reserved keyword. If at all you want to use them, you should use `, like, `index`. I personally don't prefer using reserved keywords.
Here is a list of reserved keywords.
Ignorance is definitely not bliss!

*PM asking for help will be ignored*
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