|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Hi Guys,
I have a problem! I have this php script to search a MySQL database on my server. It is set up to check and see if a particular name is already in the database. If the name is in the database, It is set up to say, "WE ARE VERY SORRY! THE NAME THAT YOU HAVE SELECTED IS ALREADY REGISTERED. PLEASE TRY ANOTHER NAME." And then it prints a URL to take them back to the page to search again. If the result of the search is negative, It will redirect them to a registration page so that they can register the name. My question is, How do I make it display the search page automaticaly when the search results is poastive insted of all that "WE ARE VERY SORRY! THE NAME THAT YOU HAVE SELECTED IS ALREADY REGISTERED. PLEASE TRY ANOTHER NAME."? I will leave a copy of my script bellow for you to see. <html> <body> <?php mysql_connect (localhost, dbase, anerson1); mysql_select_db (domainnames); if ($domain_name == "") {$domain_name = '%';} $result = mysql_query ("SELECT * FROM aarp WHERE domain_name LIKE '$domain_name' "); if ($row = mysql_fetch_array($result)) { do { print $row["<CENTER>domain_name"]; print ("<P>"); } while($row = mysql_fetch_array($result)); print ("<CENTER>WE ARE VERY SORRY!</CENTER>"); print ("<P>"); print ("<CENTER>THE NAME THAT YOU HAVE SELECTED IS ALREADY REGISTERED.</CENTER>"); print ("<P>"); print ("<CENTER>PLEASE TRY ANOTHER NAME.</CENTER>"); print ("<P>"); print ("<CENTER><a href="http://liberty.phpwebhosting.com/~dbase/search/.aarp2.html">CLICK HERE TO SEARCH AGAIN!</a></CENTER>"); print ("<P>"); } else {include("http://liberty.phpwebhosting.com/~dbase/register/.afcregister.html");} ?> </body> </html> |
|
#2
|
||||
|
||||
|
Why not just put it all on one form.
<?if ($submit){ // IF SUBMIT BUTTON PRESSED // do mysql_query here - assume $result carries sucess or failure }?> <? if(!$submit | | $result){?> //IF SUBMIT NOT PRESSED YET OR DOMIAN ALREADY TAKEN DISPLAY INPUT FORM// <?if ($result){ .... sorry please try again etc....}?>// DISPLAY ONLY IF DOMAIN TAKEN// form for domain request input here...action="<? echo $PHP_SELF;?>"> <input type="submit" name="submit" value="search"> <? } else { ?> //IF SUBMIT PRESSED OR RESULT IS FALSE // <? include("registration.form")?> <? } ?>//END ELSE// ------------------ Simon Wheeler FirePages -DHTML/PHP/MySQL |
|
#3
|
|||
|
|||
|
Ha Guys, I found the answer! It works great.<html>
<body> <?php mysql_connect (localhost, dbase, anerson1); mysql_select_db (domainnames); if ($domain_name == "") {$domain_name = '%';} $result = mysql_query ("SELECT * FROM aarp WHERE domain_name LIKE '$domain_name' "); if ($row = mysql_fetch_array($result)) { include "http://liberty.phpwebhosting.com/~dbase/search/.aarp2.html"; } else { include"http://liberty.phpwebhosting.com/~dbase/register/.aarpregister.html"; } ?> </body> </html> |
![]() |
| Viewing: Dev Shed Forums > Databases > MySQL Help > php to MySQL and back |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|