- This topic is empty.
-
AuthorPosts
-
May 2, 2014 at 5:44 am #169055
dnyanesh
ParticipantHello Traq,
i am trying to insert data into the database. could you please help to understand where i went wrong. i am inserting information but database is storing the field names in the database like username, password ,firstname, lastname ……in last mail you said while writing insert query use $ help me to understand how i can use it.
here is the code –
<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>
<html xmlns=”http://www.w3.org/1999/xhtml”>
<head>
<meta http-equiv=”Content-Type” content=”text/html; charset=utf-8″ />
<title>User registration form</title>
<link rel=”stylesheet” type=”text/css” href=”style.css” />
</head><?php $con = mysql_connect("localhost","root",""); mysql_select_db("training",$con); if(isset($_POST['submit'])) { $username = $_POST['username']; $password = $_POST['password']; $firstname= $_POST['firstname']; $lastname = $_POST['lastname']; $email = $_POST['email']; $mobile = $_POST['mobile']; $sex = $_POST['sex']; $city = $_POST['city']; $state = $_POST['state']; $country = $_POST['country']; } $sql = "insert into user_frm values('','username','password','firstname','lastname','email','mobile','sex','city','state','country')"; $rec = mysql_query($sql); ?> <body> <div> <form id="form1" name="form1" method="post" onsubmit="return validateform()" action=""> <table class="usertbl" align="center" width="600" > <tr style="border-radius:40px"> <td colspan="2" bgcolor="#006600" width="100" align="center" style="color:#CCC" style="font-weight:bold" > User Registration Form </td> </tr> <tr> <td class="tbldata">Username :</td> <td class="tbldata"><input onfocus="if(this.value=='Username')this.value='';" value="Username" class="text" type="text" name="username" /></td> </tr> <tr> <td class="tbldata">Password :</td> <td class="tbldata"><input class="text" type="password" name="password" /></td> </tr> <tr> <td class="tbldata">First Name:</td> <td class="tbldata"><input onfocus="if(this.value=='First Name')this.value='';" value="First Name" class="text" type="text" name="firstname" /></td> </tr> <tr> <td class="tbldata">Last Name:</td> <td class="tbldata"><input onfocus="if(this.value=='Last Name')this.value='';" value="Last Name" class="text" type="text" name="lastname" /></td> </tr> <tr> <td class="tbldata">E-mail :</td> <td class="tbldata"><input onfocus="if(this.value=='E-mail')this.value=''; " value="E-mail" class="text" type="text" name="email" /></td> </tr> <tr> <td class="tbldata">Mobile :</td> <td class="tbldata"><input onfocus="if(this.value=='Mobile')this.value=''; " value="Mobile" class="text" type="text" name="mobile" /></td> </tr> <tr> <td class="tbldata">Sex :</td> <td align="center" ><input type="radio" name="sex" value="Male" checked="checked"> Male </input> <input type="radio" name="sex" value="Female"> Female </input></td> </tr> <tr> <td class="tbldata">City :</td> <td class="tbldata"><input onfocus="if(this.value=='City')this.value='';" value="City" class="text" type="text" name="city" /></td> </tr> <tr> <td class="tbldata">State :</td> <td class="tbldata"><input onfocus="if(this.value=='State')this.value=''; " value="State" class="text" type="text" name="state" /></td> </tr> <tr> <td class="tbldata">Country :</td> <td class="tbldata"><input onfocus="if(this.value=='Enter your Country')this.value=''; " value="Enter your Country" class="text" type="text" name="country" /></td> </tr> <tr> <td class="tbldata"></td> <td class="tbldata" colspan="2" ><input class="text" style="background-color: #6F6" style="border:#F00" type="submit" name="submit" value="Submit" /></td> </tr> </table> </form> <script type="text/javascript"> var frmvalidator = new Validator("form1"); frmvalidator.addValidation("mobile","maxlen=10"); frmvalidator.addValidation("mobile","numeric"); function validateform() { var x = document.forms['form1']['username'].value; if(x==null || x=="") { alert("User name must be Filled out"); return false; } if(x=="Username") { alert("Enter User name"); return false; } var x = document.forms['form1']['password'].value; if(x==null || x=="" ) { alert("Enter password and should be more than 5 digit"); return false; } if(x.length < 5) { alert("Enter 5 digit password"); return false; } var x = document.forms['form1']['firstname'].value; if(x==null || x=="") { alert("First name must be Filled out"); return false; } if(x=="First Name") { alert("Enter your first name"); return false; } var x = document.forms['form1']['lastname'].value; if(x==null || x=="") { alert("Last name must be Filled out"); return false; } if(x=="Last Name") { alert("Enter your last name"); return false; } var x = document.forms['form1']['email'].value; var atpos=x.indexOf("@"); var dotpos=x.lastIndexOf("."); if(atpos<1 || dotpos<atpos+2 || dotpos+2>=x.lenght) { alert("Not a valid Email address"); return false; } if(x==null || x=="") { alert("Email must be Filled out"); return false; } var x = document.forms['form1']['mobile'].value; if(isNaN(x) || x.indexOf(" ")!=-1) { alert("Enter Numeric Value"); return false; } if(x.length < 10) { alert("Enter 10 digit mobile number"); return false; } if(x.charAt(0)!="9") { alert("Mobile number should start with 9"); return false; } if(x==null || x=="") { alert("Mobile must be Filled out"); return false; } var x = document.forms['form1']['city'].value; if(x==null || x=="") { alert("City must be Filled out"); return false; } if(x=="City") { alert("Enter your City"); return false; } var x = document.forms['form1']['state'].value; if(x==null || x=="") { alert("State must be Filled out"); return false; } if(x=="State") { alert("Enter your State"); return false; } var x = document.forms['form1']['country'].value; if(x==null || x=="") { alert("Country must be Filled out"); return false; } if(x=="Enter your Country") { alert("Enter your Country"); return false; } } </script> </div> </body> </html>
May 2, 2014 at 7:25 am #169066__
ParticipantI made a reply in your original discussion (why did you start a new discussion on this same topic?), but it seems to have disappeared.
I will see if a moderator can get my post back. It would be much better to keep the conversation in one place. In addition, my post touched on a few topics that would be important to discuss before you continue.
May 2, 2014 at 7:36 am #169072Paulie_D
MemberCan’t see anything ‘Pending’ in the stack so it looks like the reply might have hit the filter and gotten remove.
May 2, 2014 at 9:09 am #169081__
ParticipantCan’t see anything ‘Pending’ in the stack so it looks like the reply might have hit the filter and gotten remove.
Crap. It was a big one. It displayed (to me, anyways) for about an hour and a half, then it was gone this morning.
@dnyanesh, I’ll try to reconstruct it for you. I’m going to post back in the original discussion, though, so things don’t get confusing.See you there
-
AuthorPosts
- The forum ‘Back End’ is closed to new topics and replies.