-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnew.php
46 lines (40 loc) · 1.08 KB
/
new.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<?php
define('DB_HOST', 'localhost');
define('DB_NAME', 'faq');
define('DB_USER','root');
define('DB_PASSWORD','');
$con=mysql_connect(DB_HOST,DB_USER,DB_PASSWORD) or die("Failed to connect to MySQL: " . mysql_error());
$db=mysql_select_db(DB_NAME,$con) or die("Failed to connect to MySQL: " . mysql_error());
function NewUser()
{
$fname = $_POST['fname'];
$lname = $_POST['lname'];
$email = $_POST['email'];
$mesg = $_POST['mesg'];
$query = "INSERT INTO question (fname,lname,email,message) VALUES ('$fname','$lname','$email','$mesg')";
$data = mysql_query ($query)or die(mysql_error());
if($data)
{
echo "Query is submitted...";
}
}
function SignUp()
{
if(!empty($_POST['lname'])) //checking the 'user' name which is from Sign-Up.html, is it empty or have some text
{
$query = mysql_query("SELECT * FROM question WHERE lname = '$_POST[lname]' AND message = '$_POST[mesg]'") or die(mysql_error());
if(!$row = mysql_fetch_array($query) or die(mysql_error()))
{
newuser();
}
else
{
echo "SORRY...YOU ALREADY ENTERED A QUERY...";
}
}
}
if(isset($_POST['submit']))
{
SignUp();
}
?>