Jump to content

[SOLVED] Prob. compairing mysql result with $_POST result


Greaser9780

Recommended Posts

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

 

<html>

<head>

 

<title>Untitled</title>

 

</head>

 

<body>

 

<form action="bhdsingle_create.php" method="post">

Clan Name:<input type="text" name="clan_name">

Logo:<input type="text" name="logo">

Message:<input type="text" name="message">

Email:<input tupe="text" name="email">

AIM Handle:<input type="text" name="aim">

Yahoo Handle:<input type="text" name="yahoo">

MSN Handle:<input type="text" name="msn">

<button type="submit">Submit</button>

</form>

 

</body>

</html>

 

Link to comment
Share on other sites

If anyone cares I finally figured it out.The following is what actually worked:

 

$sql_select = "SELECT `clan_name` FROM `bhdsingle` WHERE `clan_name`='$clan_name' ";

$result= mysql_query($sql_select) or die(mysql_error());

 

   if (mysql_num_rows($result) == 1 ) {

        echo "Sorry, that clan name is already registered here at PST. Please  choose another clan name.";

        include("bhdsingle_join_form.html");

         

} else {

 

$sql = "INSERT INTO `bhdsingle` (clan_name, logo, message, email, aim, yahoo, msn, signup_date)

        VALUES('$clan_name', '$logo', '$message', '$email', '$aim', '$yahoo', '$msn', now() )" or die (mysql_error());

$sql_result=mysql_query($sql)or die(mysql_error());

 

    echo "Congratulations on registering your new clan for the BHD Singles Ladder!";

}

:) :) :) :)

Link to comment
Share on other sites

please try this as your way is not safe try ok.

 

 

use the page as it is ok.

 

<?php
$database=mysql_connect("localhost","username","password");
$mysql_select_db( "database_name" , $database);


$clan_name=addslashes($_POST['clan_name']);
$logo=addslashes($_POST['logo']);
$message=addslashes($_POST['message']);
$email=addslashes($_POST['email']);
$aim=addslashes($_POST['aim']);
$yahoo=addslashes($_POST['yahoo']);
$msn=addslashes($_POST['msn']);


$sql_select = "SELECT * FROM `bhdsingle` WHERE `clan_name`='$clan_name' ";
$result= mysql_query($sql_select) or die(mysql_error());

   if (mysql_num_rows($result) == 1 ) {
        echo "Sorry, that clan name is already registered here at PST. Please  choose another clan name.";
        include("bhdsingle_join_form.html");
         
} else {

if($_POST['submit']){

$sql = "INSERT INTO `bhdsingle` (clan_name, logo, message, email, aim, yahoo, msn, signup_date
        VALUES('$clan_name', '$logo', '$message', '$email', '$aim', '$yahoo', '$msn', 'now() )" or die (mysql_error());
$sql_result=mysql_query($sql)or die(mysql_error());

    echo "Congratulations on registering your new clan for the BHD Singles Ladder!";
}
}
?>




<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<html>
<head>
   
<title>Untitled</title>

</head>

<body>

<form action=" " method="post">
Clan Name:<input type="text" name="clan_name">
Logo:<input type="text" name="logo">
Message:<input type="text" name="message">
Email:<input tupe="text" name="email">
AIM Handle:<input type="text" name="aim">
Yahoo Handle:<input type="text" name="yahoo">
MSN Handle:<input type="text" name="msn">
<input type="submit" name="submit" value="submit">
</form>

</body>
</html>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.