473,387 Members | 1,374 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Not showing insert data in database

My code is correct not showing any kind of error. But the data is not inserted in the database the code is below.

Expand|Select|Wrap|Line Numbers
  1. <html> <head> <title>Untitled Document</title> </head> <body> <center> <form action="http://bytes.com/signup.php" method="post"> <table width="400" border="1" cellspacing="3" cellpadding="3"> <tr> <td width="195" bgcolor="#33FF33"><div align="justify"><em><strong>Name</strong></em></div></td> <td width="178"><input name="name" type="text"/></td> </tr> <tr> <td bgcolor="#33FF33"><div align="justify"><em><strong>Password</strong></em></div></td> <td><input name="password" type="password"/></td> </tr> <tr> <td bgcolor="#33FF33"><div align="justify"><em><strong>Email</strong></em></div></td> <td><input name="email" type="text" /></td> </tr><tr><table><tr><input name="submit" type="submit" value="submit" /></tr></table></tr> </table> </form> </center> </body> </html> <?php
  2.  
  3. $con=mysql_connect('localhost','root','') or die (mysql_error());
  4. $db=mysql_select_db('zohaib',$con) or die (mysql_error());
  5.  
  6. if(isset($_POST['submit'])){
  7.   $name=$_POST['name'];
  8.   $password=$_POST['password'];
  9.   $email=$_POST['email'];
  10.  
  11.   if($name==''){
  12.     echo "<script>alert('Please enter the Number')</script>";
  13.     exit();
  14.   }
  15.   if($password==''){
  16.     echo "<script>alert('Please enter the Number')</script>";
  17.     exit();
  18.   }
  19.   if($email==''){
  20.     echo "<script>alert('Please enter the Number')</script>";
  21.     exit();
  22.   }
  23.   else {
  24.     $que="insert into table (name,password,email) values ('$name','$password','$email')";
  25.  
  26.     if(mysql_query($a)){
  27.       echo "<script>window.open('welcome.php','_self')</script>";
  28.  
  29.     }
  30.  
  31.   }
  32.  
  33. }
  34.  
  35. ?>
Oct 9 '15 #1
3 1421
RonB
589 Expert Mod 512MB
I've added the code tags for you, but in the future please make sure you wrap your code with the code tags.

Please fix the formatting of that first line to include line breaks in their proper locations so that your code is readable.

You claim your code is correct, but you have echo statements after you terminated the body and html tags.
Oct 9 '15 #2
tdrsam
97 64KB
I think you need to execute your query. So after:

Expand|Select|Wrap|Line Numbers
  1. $que="insert into table (name,password,email) values ('$name','$password','$email')";
  2.  
You might need something like:

Expand|Select|Wrap|Line Numbers
  1.  
  2. $result = mysql_query($que);
This will fire the query

Also, this version of MySQL is deprecated. You should look at the manual when you need help with MySQL, and also to see how the new versions are used.
Oct 12 '15 #3
Expand|Select|Wrap|Line Numbers
  1. $sql="insert into ['table name'] values('".$name."','".$password."','".$password."')";
  2. $i=mysql_query($sql);
  3.  if(mysql_query($sql)){
  4.       echo "<script>window.open('welcome.php','_self')</script>";
  5. }
  6.  
  7.  
Oct 13 '15 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Santo Santis | last post by:
How can I make an .exe file that can insert data automatically in a SQLServer database, I can do it in C, but how can I connect to SQLServer and execute a query. All data that I have to insert...
0
by: Dinu | last post by:
Hi All I am trying to insert data within a transaction, into a Db2 database from asp.net. I have created a System DSN using ISeries Access Driver(32 bit) for Windows. I am then connecting...
1
by: Pratik Gupte | last post by:
I have created a database in .mdf format, but I am unable to insert data into its tables. Can anybody help how to insert data using ASP.Net 2.0 using SQL Server 2005 Express edition in windows...
3
by: andrewtayloruk | last post by:
I'm a newbie when it come to things php and i'm having a bit of trouble. I'm trying to insert data from an html form into a mysql database and can't get it to work. Just a few bits about my...
0
by: danishce | last post by:
Hello, I want to insert data directly into my windows form data grid and load a combobox(userid) in the 1st column of data grid,a textbox(password) in 2nd column of datagrid. The code for insert...
1
by: Doc11 | last post by:
I'm trying to allow users insert data into a database using the form view. But when I click the insert button I get this error: Server Error in '/Customer Database' Application....
0
by: akshalika | last post by:
I am new to Biztalk. In my project we need to connect oracle database and insert data into oracle table using BizTalk project. I use WCF Adapter pack(SP2). I create biztalk project then using Consume...
2
by: megha17 | last post by:
// this is testcon.php <?php include'createConnection.php'; $no=$_POST;// fatal error occur $nm=$_POST;// fatal error occur
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.