#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. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Jul 2000
    Posts
    669
    Rep Power
    15
    Not sure why you would query the db when a $domain_name was not supplied, I migth take this approach but just a suggestion

    <html>
    <body>

    <?php

    mysql_connect (localhost, dbase, anerson1);

    mysql_select_db (domainnames);

    if ($domain_name != "") {
    $result = mysql_query ("SELECT * FROM aarp
    WHERE domain_name LIKE '$domain_name'
    ");
    }
    else {
    print "You must supply a domain name";
    exit;
    }

    if (!$result) {
    print "<center>" . $domain_name;
    print "<P>";
    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>

  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
    Hi Freddy,
    That script did not do it either! I am supplying a domain Name, From the search page, That is where you put the domain name in.
  6. #4
  7. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Posts
    8
    Rep Power
    0
    Try this:

    <html>
    <body>

    <?php

    $db = mysql_connect (localhost, dbase, anerson1);

    mysql_select_db (domainnames);

    $result = mysql_query ("SELECT * FROM aarp
    WHERE domain_name LIKE '%$domain_name%'
    ", $db);

    if (mysql_num_rows($result) > 0) {
    include("http://liberty.phpwebhosting.com/~dbase/register/.afcregister.html");
    }

    else {
    print "<center>" . $domain_name;
    print "<P>CENTER>WE ARE VERY SORRY!</CENTER><P><CENTER>THE NAME THAT YOU HAVE SELECTED IS ALREADY REGISTERED.</CENTER>";
    print "<P><CENTER>PLEASE TRY ANOTHER NAME.</CENTER><P><CENTER><a href="http://liberty.phpwebhosting.com/~dbase/search/.aarp2.html">CLICK HERE TO SEARCH AGAIN!</a></CENTER><P>";
    }


    ?>

    </body>


  8. #5
  9. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Posts
    8
    Rep Power
    0
    By the way, what error are you getting. Also mysql_select_db should be:

    mysql_select_db ("domainnames", $db);
  10. #6
  11. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2000
    Location
    Dallas, Texas USA
    Posts
    9
    Rep Power
    0
    Hi Louie,
    Thanks for the help!, However, It is not the answer. What you have sent is good, But, Not quite. It will only redirect to the first include
    "if (mysql_num_rows($result) > 0) {
    include("http://liberty.phpwebhosting.com/~dbase/register/.afcregister.html");"
    It will not redirect to the other URL if the results of the search is posative.
  12. #7
  13. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2000
    Location
    Dallas, Texas USA
    Posts
    9
    Rep Power
    0
    Hi Louie,
    Forgot to tell you, I am receiving no error.
  14. #8
  15. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2000
    Posts
    17
    Rep Power
    0
    if(mysql_num_rows($result)>0){

    echo "<meta http-equiv="refresh" content="0;url=http://liberty.phpwebhosting.com/~dbase/register/.afcregister.html/">";

    Hmmm, maybe this script could give you an idea.
  16. #9
  17. .Net Developer
    Devshed Novice (500 - 999 posts)

    Join Date
    Feb 2000
    Location
    London
    Posts
    987
    Rep Power
    15

    <<
    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."?
    >>

    yea, you have two options here.
    First option is that,include that seacrh form here again using include()and display a message "Domain already taken.Try another one here".

    Second option is that print again that form codes directly..

    i would suggest you to do something like following.

    <?php
    if(isset($submit)){
    // When user clicks on search domain..

    $con=mysql_connect ('localhost','dbase', 'anerson1');
    //connection string..
    mysql_select_db ('databasename',$con);
    //select your db
    $result = mysql_query ("SELECT * FROM aarp
    WHERE domain_name='$domain_name'
    ",$con);

    //issue sql statement

    if (mysql_num_rows($result)>0){
    //domain is already taken..

    echo "$domain_name already taken.Try another one heren";
    echo "<form action="$PHP_SELF" method="post">n";
    echo "Enter a Domain name: <input type="text" name="domain_name">n";
    echo "<input type="submit" name="submit" value="submit">n";
    echo "<form>n";
    }else{
    header("Location: afcregister.htmlnn");
    //Redirect to registration page
    //or you can include the registration form using include()...

    //include("http://liberty.phpwebhosting.com/~dbase/register/.afcregister.html");

    }
    }else{
    echo "Error!!n";
    exit;
    }
    ?>

    if you are using the header() function for redirecting the page to registartion page then make sure that no white space or html tags are their before your php deliminator(ie, before "<?").



    ------------------
    SR -
    webshiju.com

    "The fear of the LORD is the beginning of knowledge..."

    [This message has been edited by Shiju Rajan (edited August 05, 2000).]

Similar Threads

  1. MySQL for phpBB in PHP
    By Tyme66 in forum Project Help Wanted
    Replies: 13
    Last Post: February 26th, 2004, 02:28 AM
  2. Replies: 0
    Last Post: February 12th, 2004, 12:56 PM
  3. Replies: 14
    Last Post: February 8th, 2004, 02:28 PM
  4. Replies: 0
    Last Post: February 2nd, 2004, 06:44 PM
  5. Replies: 0
    Last Post: January 30th, 2004, 02:22 PM

IMN logo majestic logo threadwatch logo seochat tools logo