#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2000
    Location
    Dallas, Texas USA
    Posts
    9
    Rep Power
    0
    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. #2
  3. Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Feb 2000
    Location
    Perth West Australia
    Posts
    757
    Rep Power
    15
    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 &#0124; &#0124; $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
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2000
    Location
    Dallas, Texas USA
    Posts
    9
    Rep Power
    0
    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>

Similar Threads

  1. Replies: 0
    Last Post: February 12th, 2004, 11:56 AM
  2. Replies: 14
    Last Post: February 8th, 2004, 01:28 PM
  3. Get info from MySQL into php page?
    By Dr_DK in forum PHP Development
    Replies: 2
    Last Post: February 5th, 2004, 07:22 PM
  4. Replies: 0
    Last Post: February 2nd, 2004, 05:44 PM
  5. Replies: 0
    Last Post: January 30th, 2004, 01:22 PM

IMN logo majestic logo threadwatch logo seochat tools logo