Jump to content

Basic MySQL/PHP Form Help Please!


jamieh

Recommended Posts

Hi there,

 

I'm new to this forum so hi to everyone  ::)

 

I've just started learning PHP, and i'm trying to create a basic for for people to signup to gaming tournaments etc.

 

It's only REALLY basic so only consists of a few lines as we speak, but will make it a lot bigger as i get better.

 

I'm having some problems with if commands etc, trying to use variables with mysql and so on..

 

Here is the little script i have here following the odd tutorial:

 

insert.php

<?php

$con = mysql_connect("localhost","fuzglcom_jamie","vectra111");

if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }
mysql_select_db("fuzglcom_fuzcup", $con);
$sql="INSERT INTO teams (TeamName, Website, Email, Leader)
VALUES
('$_POST[teamname]','$_POST[website]','$_POST[email]','$POST_[leader]')";

if (!mysql_query($sql,$con))
  {
  die('Error: ' . mysql_error());
  }
echo "1 record added";

else { ($count > 0) {
   echo "Email already in database!";
}

mysql_close($con)

?>

 

config.php

<?php

$email = mysql_query("SELECT * FROM teams WHERE email = '[$POST_[email]'") or die (mysql_error());
$count = mysql_num_rows($email);

?>

 

Here's the error i face:

 

Parse error: syntax error, unexpected T_ELSE in /home1/fuzglcom/public_html/test/insert.php on line 20

 

Pretty simple to you coders i know i've nested something wrong or i obviously need to get the hang of IF commands and where they go etc. I may well easily be an idiot ::) but if you could possibly help me that would be great.

 

Many thanks,

Jamie

 

Link to comment
https://forums.phpfreaks.com/topic/105480-basic-mysqlphp-form-help-please/
Share on other sites

<?php

$con = mysql_connect("localhost","fuzglcom_jamie","vectra111");

if (!$con) { die('Could not connect: ' . mysql_error()); }
mysql_select_db("fuzglcom_fuzcup", $con);

$sql1 = sprintf("SELECT * FROM `teams` WHERE `Email` = '%s'", $_POST['email']);
$result1 = mysql_query($sql1,$con);

if (!$result1) { 
  die('Error: ' . mysql_error());
}

if (mysql_num_rows($result) > 0) {
     die("WE ALREADY HAVE THAT EMAIL ADDRESS");
}

$sql="INSERT INTO teams (TeamName, Website, Email, Leader)
VALUES
('$_POST[teamname]','$_POST[website]','$_POST[email]','$POST_[leader]')";

if (!mysql_query($sql,$con))
  {
  die('Error: ' . mysql_error());
  }
echo "1 record added";

mysql_close($con)

?>

 

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.