| | |
How to POST the data to second page?
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
0
#12 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?
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?
CodeJoust! Design + Development - Proud User of Ubuntu
•
•
Join Date: Apr 2008
Posts: 29
Reputation:
Solved Threads: 0
0
#13 Oct 7th, 2009
•
•
•
•
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?
PHP Syntax (Toggle Plain Text)
<html> <head> <title>Index</title> </head> <div style="position: absolute; width: 1146px; height: 842px; z-index: 1; left:10px; top:1px" id="layer2" align="center"> <body background="E-Filing%20Management%20System%20Picture/Snow.gif"> <p align="center"> <img border="0" src="E-Filing%20Management%20System%20Picture/logo-RR-gif.gif" width="957" height="245"></p> <p align="center"><span lang="zh-cn"> </span></p> <p align="center"><span lang="zh-cn"><img border="0" src="E-Filing%20Management%20System%20Picture/Association.gif" width="491" height="74"></span></p> <p align="center"><span lang="zh-cn"> </span></p> <div style="position: absolute; width: 191px; height: 28px; z-index: 2; left: 546px; top: 441px" id="layer4"> <font color="#FFFFFF"><span lang="en-us"> <font size="4" face="Arial Rounded MT Bold"> Association Name</font></span></font></div> <div style="position: absolute; width: 70px; height: 24px; z-index: 1; left: 298px; top: 442px" id="layer3"> <font size="4" face="Arial Rounded MT Bold"><font color="#FFFFFF"><span lang="en-us"> Index</span></font></font></div> <p align="center"><span lang="zh-cn"> </span><font color="#FFFFFF"><span lang="en-us"> <font face="Arial Rounded MT Bold"> </font> <font size="4" face="Arial Rounded MT Bold"> </font></span></font></p> <p align="center"><span lang="en-us"> </span> <form method='POST' action='AssociationAdd.php'> <input type='text' name='T2' size='11'> <input type='text' name='T1' size='77'></p> <p> <input type='submit' value=' Add ' name='submit' style='font-family: Times New Roman; color: #000000; font-weight: bold; font-size: 12pt'> <input type='reset' value=' Reset ' name='B2' style='font-family: Times New Roman; color: #000000; font-weight: bold; font-size: 12pt'> <input type='submit' value=' Back ' name='submit' style='font-family: Times New Roman; color: #000000; font-weight: bold; font-size: 12pt'></p> <?php if(isset($_POST["submit"])) { $submit = $_POST["submit"]; $T2= $_POST["T2"]; $T1 = $_POST["T1"]; if($submit==" Add ") { print "<script language ='javascript'>window.location.href='AssociationAddProcess.php?T2=$T2&T1=$T1'</script>"; } else if($submit==" Back ") { print "<script language ='javascript'>window.location.href='Association.php'</script>"; } } ?> </form> <p align="center"> </p> <p align="center"> </p> <p align="center"> </p> <p align="center"> </p> <p align="center"> </p> </div> </body> </html>
and this is "AssociationAddProcess.php"
PHP Syntax (Toggle Plain Text)
<html> <head> <title>Index</title> </head> <body background="E-Filing%20Management%20System%20Picture/Snow.gif"> <p align="center"> <img border="0" src="E-Filing%20Management%20System%20Picture/logo-RR-gif.gif" width="957" height="245"></p> <p align="center"><span lang="zh-cn"> </span></p> <p align="center"><span lang="zh-cn"><img border="0" src="E-Filing%20Management%20System%20Picture/Association.gif" width="491" height="74"></span></p> <?php $id = $_GET['T2']; $an = $_GET['T1']; if ($id==null||$an==null) { print" <p align='center'> </p> <table width='400' height='200' border='1' align='center' bordercolor='#66FF00'bgcolor='#0000FF'> <td><div align='center'><font color='#FF0000' size='5'><p>Please Enter Index and Association Name Completely</p> </font></div></td> </tr> </table></td> </tr> </table></td> </tr> </table></td> </tr> </table> "; print "<p align='center'> </p>"; echo "<HTML><META HTTP-EQUIV='REFRESH' CONTENT='2; URL=AssociationAdd.php'> <CENTER><p> </p><p> <tr> <td align='center'><h12>please wait...</h12></td> </tr> </table><p> </p><p> </p></CENTER></BODY></HTML>"; } else { $connection=mysql_connect("localhost","root","") or die("<font color='#FFFFFF'>Could not connect to MySQL</font>".mysql_error()); $selection=mysql_select_db("efiling") or die("<font color='#FFFFFF'>Unable to select database.</font>".mysql_error()); $sql2 = "SELECT * from association Where AssociationName='$an'"; $result2 = mysql_query($sql2) or die("<font color='#FFFFFF'>SQL select statement failed</font>"); if (mysql_num_rows($result2) < 1) { $sql = "INSERT INTO association(Index, AssociationName) VALUES ('$id', '$an')"; $result=mysql_query($sql) or die("<font color='#FFFFFF'>SQL select statement failed</font>"); if ($result) { print "<script language ='javascript'>window.alert('Added Succesfully!');window.location.href='AssociationAdd.php'</script>"; } else { die(mysql_error()); } } else { print"<p align='center'> </p> <table width='400' height='200' border='1' align='center' bordercolor='#66FF00'bgcolor='#0000FF'> <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> </tr> </table></td> </tr> </table></td> </tr> </table></td> </tr> </table> "; print "<p align='center'> </p>"; echo "<HTML><META HTTP-EQUIV='REFRESH' CONTENT='2; URL=AssociationAdd.php'> <CENTER><p> </p><p> <tr> <td align='center'><h12>please wait...</h12></td> </tr> </table><p> </p><p> </p></CENTER></BODY></HTML>"; } } ?> <p align="center"> </p> <p align="center"> </p> <p align="center"> </p> <p align="center"> </p> <p align="center"> </p> </body> </html>
I tested by edit the echo already, the database error is here :
PHP Syntax (Toggle Plain Text)
if (mysql_num_rows($result2) < 1) { $sql = "INSERT INTO association(Index, AssociationName) VALUES ('$id', '$an')"; $result=mysql_query($sql) 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
-1
#15 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.
Here is a list of reserved keywords.
Ignorance is definitely not bliss!
*PM asking for help will be ignored*
*PM asking for help will be ignored*
![]() |
Similar Threads
- pass data to next page (PHP)
- POSTing data to web page (Python)
- Using urllib2 to post data (Python)
- Button to send POST data (JavaScript / DHTML / AJAX)
- POST data issue when return to page (PHP)
- Simple question: Popup page to post data to mother page (PHP)
- i want to post data with screen scrap page.. (ASP.NET)
Other Threads in the PHP Forum
- Previous Thread: Dynamic Photo Galley or Slide Show
- Next Thread: String Help
| Thread Tools | Search this Thread |
apache api array beginner binary body broken buttons cakephp checkbox class cms code cron curl database date date/time display dynamic ebooks echo email error file files folder form forms function functions global google href htaccess html image include insert ip javascript joomla limit link list login mail mediawiki menu mlm msqli_multi_query multiple mycodeisbad mysql number oop parameter paypal pdf php phpincludeissue problem query radio random recourse recursion regex remote script search seo server sessions sms source sp space speed sql static subdomain syntax system table tag tutorial update upload url validator variable vbulletin video web webdesign white wordpress xml youtube







