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>

 

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!";

}

:) :) :) :)

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>

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.