473,666 Members | 2,121 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Why is my php value not being inserted into the database?

1 New Member
<?php
include 'connection.php ';
if(isset($_POST['submit']))
{
$name1=$_POST['name'];
$email1=$_POST['email'];
$re_email1=$_PO ST['email1'];
$npass1=$_POST['pass'];
$npass2=$_POST['pass1'];
$phone1=$_POST['phone'];
$state1=$_POST['state'];
$city1=$_POST['city'];
$street1=$_POST['street'];
$pin1=$_POST['pin'];
$sql="INSERT INTO user_details (uname,email,re _email,pass1,pa ss2,phone,ustat e,city,street,p in) VALUES ('$name1','$ema il1','$re_email 1','$npass1','$ npass2','$phone 1','$state1','$ city1','$street 1','$pin1')";
// $sql="INSERT INTO user_details (uname,email,re _email,pass1,pa ss2,phone,ustat e,city,street,p in) VALUES ('$name1','".$e mail1."','".$re _email1."','".$ npass1."','".$n pass2."','".$ph one1."','".$sta te1."','".$city 1."','".$street 1."','".$pin1." ')";
$result=mysqli_ query($conn,$sq l);
if($result)
{
echo "<br>User has been registered";
header('Locatio n: mainpage.php');
exit;
}
else{
echo "Error:".$sql." :-".mysqli_error( $conn);
}
mysqli_close($c onn);
}
?>
<html>
<head>
<title>SignUp </title>
<style>
#carlogo{
width:120px;
height:120px;
padding-top: 2px;
border-radius: 80%;
}

#company_name{
font-size: xx-large;
font-weight: bolder;
padding: 30px;
font-family: 'Courier New', Courier, monospace;
}
.topnavigation{
background-blend-mode: difference;
display:flex;
align-items: center;
box-shadow: 0 0px 0px 0 rgba(0, 0, 0, 0), 0 6px 20px 0 rgba(0, 0, 0, 0.0);
box-sizing: border-box;
/* border:white; */
/* border-width:3px; */
/* border-bottom: white; */
}
body{
background-image: url("images/pexels-garvin-st-villier-3311574.jpg");
margin:0px;
margin-top: 20px;
padding: 0px;
background-size: cover ;
zoom: 0;
min-height: 500px;
background-attachment: fixed;
background-position: center;
background-repeat: no-repeat;
background-size: cover;
font-family: 'Franklin Gothic Medium', 'Arial Narrow', Arial, sans-serif;
}
label{
font-family: 'Franklin Gothic Medium', 'Arial Narrow', Arial, sans-serif;
font-weight: bold;
color: white;
}
.signup{
border-radius: 25px;
border: 4px solid yellow;
background-color:rgb(32, 32, 32);
margin-left: 50px;
margin-top: 30px;
margin-bottom: 20px;
padding: 20px;
width: 400px;
height: auto;
}
.signup:hover{
background-color: rgb(70, 68, 68);
border: 4px solid yellow
}

.register{
opacity: 0.9;
background-blend-mode: difference;
}
.para{
font-weight: bolder;
font-size:larger;
text-align: center;
}
.button{
background-color: yellow;
border:none;
color:black;
font-weight: bolder;
padding:8px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 18px;
margin:0px 2px;
cursor: pointer;
border-radius: 15px;
transition: 0.3s;
width:40%;
margin-left: auto;

}
.button:hover{
background-color: black;
color:white;
}
input[type=text], select,input[type=email],input[type=password],input[type=number],input[type=tel],textarea[type=text] {
width: 100%;
padding: 12px 20px;
margin: 8px 0;
display: inline-block;
border: 1px solid #ccc;
border-radius: 4px;
box-sizing: border-box;
}

</style>
<script type='text/JavaScript'>
function check(){
var letters= /^[A-Za-z]+$/;
var numbers = /^[0-9]+$/;


//password validation
if((signupform. pass.value.leng th < "6") || (signupform.pas s1.value.length <"6") ||(signupform.p ass.value > "8")||(signupfo rm.pass1.value > "8")){
alert("!! Invalid Password. Enter Password with 6-8 characters !!");
pass.focus();
pass2.focus();
return false;
}
if(signupform.p ass.value != signupform.pass 1.value){
alert("! Both the passwords does not match !");
pass.focus();
pass1.focus();
return false;
}

//email validation
if(signupform.e mail.value != signupform.emai l1.value){
alert("! Both the Email Addresses does not match !")
email.focus();
email1.focus();
return false;
}

//phone number validation
if((signupform. phone.value.len gth >10)||(signupfo rm.phone.value. length <9)){
alert("Invalid Phone no, Must contain only 10 digits")
phone.focus();
return false;
}

// window.location .href="login.ht ml";
alert("User has been successfully Registered");
true;
}
</script>
</head>
<body>
<div class="topnavig ation">
<img id="carlogo" src="images/download.jfif" alt="Avatar">
<span id="company_nam e">CLASSICS CUSTOMS</span>
</div>
<div class="register " >
<div class="signup">
<form name="signupfor m" method="POST" onsubmit="retur n check()" action="mainpag e.php">
<center><b><h 2 style="color: white;">Enter your Details to SignUp</h2></b></center>
<label>Name :</label><input type="text" name="name" id="name" placeholder="En ter Full Name" required><br><b r>
<label>Email :</label><input type="email" name="email" id="email" placeholder="En ter Email" required><br><b r>
<label>Confir m Email :</label><input type="email" name="email1" id="email1" placeholder="Re-enter Email" required><br><b r>
<label>Passwo rd :<label><input type="password" name="pass" id="pass" placeholder="En ter Password of maximum 10 digits"required ><br><br>
<label>Confir m Password :</label><input type="password" name="pass1" id="pass1" placeholder="Re-enter Password"><br>< br>
<label>Mobile No :</label><input type="tel" name="phone" id="phone" placeholder="En ter Phone no"><br><br>
<label>State :</label>
<select name="state" id="state">
<option value="Kerala"> Kerala</option>
<option value="Tamil Nadu">Tamil Nadu</option>
<option value="Karnatak a">Karnataka </option>
<option value="Andhra Pradesh">Andhra Pradesh</option>
<option value="Goa">Goa </option>
<option value="Maharast ra">Maharastr a</option>
<option value="Gujarat" >Gujarat</option>
<option value="Madhya Pradesh">Madhya Pradesh</option>
</select><br><br>
<label>City :</label><input type="text" name="city" id="city" placeholder="En ter your city"><br><br>
<label>Street/Address :</label><textarea type="text" name="street" id="street" placeholder="En ter your street"></textarea><br><b r>
<label>PinCod e :</label><input type="number" name="pin" id="pin" placeholder="En ter your PinCode"><br><b r>
<center><butt on class="button" name="submit">S ignUp</button></center>
<!-- <center><input* type="submit"*c lass="button"*n ame="submit"*va lue="Signup"></center> -->
</form>
</div>
</div>

</body>
</html>

<!-- pattern="^\d{6} $" -->
Sep 17 '21 #1
2 15194
dev7060
644 Recognized Expert Contributor
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. include 'connection.php';
  3. if(isset($_POST['submit']))
  4. {
  5. $name1=$_POST['name'];
  6. $email1=$_POST['email'];
  7. $re_email1=$_POST['email1'];
  8. $npass1=$_POST['pass'];
  9. $npass2=$_POST['pass1'];
  10. $phone1=$_POST['phone'];
  11. $state1=$_POST['state'];
  12. $city1=$_POST['city'];
  13. $street1=$_POST['street'];
  14. $pin1=$_POST['pin'];
  15. $sql="INSERT INTO user_details (uname,email,re_email,pass1,pass2,phone,ustate,cit y,street,pin) VALUES ('$name1','$email1','$re_email1','$npass1','$npass 2','$phone1','$state1','$city1','$street1','$pin1' )";
  16. // $sql="INSERT INTO user_details (uname,email,re_email,pass1,pass2,phone,ustate,cit y,street,pin) VALUES ('$name1','".$email1."','".$re_email1."','".$npass 1."','".$npass2."','".$phone1."','".$state1."','". $city1."','".$street1."','".$pin1."')";
  17. $result=mysqli_query($conn,$sql);
  18. if($result)
  19. {
  20. echo "<br>User has been registered";
  21. header('Location: mainpage.php');
  22. exit;
  23. }
  24. else{
  25. echo "Error:".$sql.":-".mysqli_error($conn);
  26. }
  27. mysqli_close($conn);
  28. }
  29. ?>
  30. <html>
  31. <head>
  32. <title>SignUp</title>
  33. <style>
  34. #carlogo{
  35. width:120px;
  36. height:120px;
  37. padding-top: 2px;
  38. border-radius: 80%;
  39. }
  40.  
  41. #company_name{
  42. font-size: xx-large;
  43. font-weight: bolder;
  44. padding: 30px;
  45. font-family: 'Courier New', Courier, monospace;
  46. }
  47. .topnavigation{
  48. background-blend-mode: difference;
  49. display:flex;
  50. align-items: center;
  51. box-shadow: 0 0px 0px 0 rgba(0, 0, 0, 0), 0 6px 20px 0 rgba(0, 0, 0, 0.0);
  52. box-sizing: border-box;
  53. /* border:white; */
  54. /* border-width:3px; */
  55. /* border-bottom: white; */
  56. }
  57. body{
  58. background-image: url("images/pexels-garvin-st-villier-3311574.jpg");
  59. margin:0px;
  60. margin-top: 20px;
  61. padding: 0px;
  62. background-size: cover ;
  63. zoom: 0;
  64. min-height: 500px;
  65. background-attachment: fixed;
  66. background-position: center;
  67. background-repeat: no-repeat;
  68. background-size: cover;
  69. font-family: 'Franklin Gothic Medium', 'Arial Narrow', Arial, sans-serif;
  70. }
  71. label{
  72. font-family: 'Franklin Gothic Medium', 'Arial Narrow', Arial, sans-serif;
  73. font-weight: bold;
  74. color: white;
  75. }
  76. .signup{
  77. border-radius: 25px;
  78. border: 4px solid yellow;
  79. background-color:rgb(32, 32, 32);
  80. margin-left: 50px;
  81. margin-top: 30px;
  82. margin-bottom: 20px;
  83. padding: 20px;
  84. width: 400px;
  85. height: auto;
  86. }
  87. .signup:hover{
  88. background-color: rgb(70, 68, 68);
  89. border: 4px solid yellow
  90. }
  91.  
  92. .register{
  93. opacity: 0.9;
  94. background-blend-mode: difference;
  95. }
  96. .para{
  97. font-weight: bolder;
  98. font-size:larger;
  99. text-align: center;
  100. }
  101. .button{
  102. background-color: yellow;
  103. border:none;
  104. color:black;
  105. font-weight: bolder;
  106. padding:8px;
  107. text-align: center;
  108. text-decoration: none;
  109. display: inline-block;
  110. font-size: 18px;
  111. margin:0px 2px;
  112. cursor: pointer;
  113. border-radius: 15px;
  114. transition: 0.3s;
  115. width:40%;
  116. margin-left: auto;
  117.  
  118. }
  119. .button:hover{
  120. background-color: black;
  121. color:white;
  122. }
  123. input[type=text], select,input[type=email],input[type=password],input[type=number],input[type=tel],textarea[type=text] {
  124. width: 100%;
  125. padding: 12px 20px;
  126. margin: 8px 0;
  127. display: inline-block;
  128. border: 1px solid #ccc;
  129. border-radius: 4px;
  130. box-sizing: border-box;
  131. }
  132.  
  133. </style>
  134. <script type='text/JavaScript'>
  135. function check(){
  136. var letters= /^[A-Za-z]+$/;
  137. var numbers = /^[0-9]+$/;
  138.  
  139.  
  140. //password validation
  141. if((signupform.pass.value.length < "6") || (signupform.pass1.value.length <"6") ||(signupform.pass.value > "8")||(signupform.pass1.value > "8")){
  142. alert("!! Invalid Password. Enter Password with 6-8 characters !!");
  143. pass.focus();
  144. pass2.focus();
  145. return false;
  146. }
  147. if(signupform.pass.value != signupform.pass1.value){
  148. alert("! Both the passwords does not match !");
  149. pass.focus();
  150. pass1.focus();
  151. return false;
  152. }
  153.  
  154. //email validation
  155. if(signupform.email.value != signupform.email1.value){
  156. alert("! Both the Email Addresses does not match !")
  157. email.focus();
  158. email1.focus();
  159. return false;
  160. }
  161.  
  162. //phone number validation
  163. if((signupform.phone.value.length >10)||(signupform.phone.value.length <9)){
  164. alert("Invalid Phone no, Must contain only 10 digits")
  165. phone.focus();
  166. return false;
  167. }
  168.  
  169. // window.location.href="login.html";
  170. alert("User has been successfully Registered");
  171. true;
  172. }
  173. </script>
  174. </head>
  175. <body>
  176. <div class="topnavigation">
  177. <img id="carlogo" src="images/download.jfif" alt="Avatar">
  178. <span id="company_name">CLASSICS CUSTOMS</span>
  179. </div>
  180. <div class="register" >
  181. <div class="signup">
  182. <form name="signupform" method="POST" onsubmit="return check()" action="mainpage.php">
  183. <center><b><h2 style="color: white;">Enter your Details to SignUp</h2></b></center>
  184. <label>Name :</label><input type="text" name="name" id="name" placeholder="Enter Full Name" required><br><br>
  185. <label>Email :</label><input type="email" name="email" id="email" placeholder="Enter Email" required><br><br>
  186. <label>Confirm Email :</label><input type="email" name="email1" id="email1" placeholder="Re-enter Email" required><br><br>
  187. <label>Password :<label><input type="password" name="pass" id="pass" placeholder="Enter Password of maximum 10 digits"required ><br><br>
  188. <label>Confirm Password :</label><input type="password" name="pass1" id="pass1" placeholder="Re-enter Password"><br><br>
  189. <label>Mobile No :</label><input type="tel" name="phone" id="phone" placeholder="Enter Phone no"><br><br>
  190. <label>State :</label>
  191. <select name="state" id="state">
  192. <option value="Kerala">Kerala</option>
  193. <option value="Tamil Nadu">Tamil Nadu</option>
  194. <option value="Karnataka">Karnataka</option>
  195. <option value="Andhra Pradesh">Andhra Pradesh</option>
  196. <option value="Goa">Goa</option>
  197. <option value="Maharastra">Maharastra</option>
  198. <option value="Gujarat">Gujarat</option>
  199. <option value="Madhya Pradesh">Madhya Pradesh</option>
  200. </select><br><br>
  201. <label>City :</label><input type="text" name="city" id="city" placeholder="Enter your city"><br><br>
  202. <label>Street/Address :</label><textarea type="text" name="street" id="street" placeholder="Enter your street"></textarea><br><br>
  203. <label>PinCode :</label><input type="number" name="pin" id="pin" placeholder="Enter your PinCode"><br><br>
  204. <center><button class="button" name="submit">SignUp</button></center>
  205. <!-- <center><input*type="submit"*class="button"*name=" submit"*value="Signup"></center> -->
  206. </form>
  207. </div>
  208. </div>
  209.  
  210. </body>
  211. </html>
  212.  
  213. <!-- pattern="^\d{6}$" -->
Why is my php value not being inserted into the database?
What is the error(s) you see? I don't see check() returning true anywhere.
Sep 18 '21 #2
bakertaylor28
45 New Member
This is your problem:

Expand|Select|Wrap|Line Numbers
  1. $sql="INSERT INTO user_details (uname,email,re_email,pass1,pass2,phone,ustate,cit y,street,pin) VALUES ('$name1','$email1','$re_email1','$npass1','$npass 2','$phone1','$state1','$city1','$street1','$pin1' )";
  2.  
The problem is that SQL doesn't know which record to file because you need a WHERE clause to identify the uname field so that SQL knows which record in the database it is modifying. Therefore we need either of the following :

Expand|Select|Wrap|Line Numbers
  1. ...
  2. // Cretate a new database record all at once. Var $foo is presumed to hold the SQL table value for uname
  3.  
  4. $sql="INSERT INTO user_details (uname,email,re_email,pass1,pass2,phone,ustate,city,street,pin) VALUES ('$foo,$name1','$email1','$re_email1','$npass1','$npass 2','$phone1','$state1','$city1','$street1','$pin1' )";
  5.  
  6. // OR we can Modify an existing record using UPDATE combined with a WHERE Clause 
  7.  
  8. ...
  9. UPDATE user_details SET email = $email, re_email = $re_email1, pass1 = $npass1, pass2 = $npass2, phone = #phone1,
  10. ustate = $state1, city = $city1, street = $street1 pin = $pin1 WHERE uname = $foo;
  11.  
Feb 26 '23 #3

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

Similar topics

8
472
by: william | last post by:
Hi Whwn I select from database using ADO.NET, if the data is null value in database, how should I handle it (string, integer, boolean type field) Thank willia
1
1766
by: garimapuri | last post by:
hi ihad an array in php and iwant to insert its value in database the coding is: <?php $nv_pairs = explode('&',$query_string); $array; list ($name, $value) = explode ('=',$nv_pairs); $i = 0; foreach($nv_pairs as $array) {
3
11179
by: kang jia | last post by:
hi i retrieved value from database and now would to put these value inside a textarea. however, it seems cant put in, but the value can be retrieved from database. i don;t know where is wrong, this the code i put in: <td><textarea ='text' COLS='40' ROWS='6' value='<? echo $detail?>'></textarea></td> can help me with it. thanks in advance:)
1
1661
by: julianomartins | last post by:
Hi friends, how I make to recoup the value of database and to keep selected in combobox to edit my form? in script below it is selected field of the table that possesss id of the first item of database. I am catching id of a URL: <?php echo "<a href='alterar_cliente.php?id=$id'>Alterar</a>"; ?>
1
1060
by: suraj srivastava | last post by:
if we want find the value witout database connection,we want value retrieve from datagrid at .aspx pages at run time. we want to connection of the pages of data value throw datagrid . how will we solve it
1
1381
by: arial | last post by:
I am having problem inserting checkbox value into database table. My database field is of type char(1). and my code is like this: string cc= null; if (chkdiscipline.checked) { cc = "T";
1
2189
by: bhargavi514 | last post by:
friends i need the code to retrieve value from database and display value in text area using php
2
2805
by: mindi | last post by:
how to retrieve single value form database without using result set. like i need only integer max(acc_id) from database and need to store in a variable
4
10739
by: coder86 | last post by:
Hi, I am new to this site . I am looking for some help in updating my database from the value selected by user. Heres my page I have a table with rows of ID and its status. Status is a drop down menu with 4 possible options. The default displayed is the value from database. When the user picks a value form drop down menu say "completed" I want this value to be updated fro that particular id to database. Heres my script to create drop...
1
2465
by: ilasenthi27 | last post by:
hi.. i'm php beginner,implementing payroll system based on salary per hour.. i want to store the time value on database.the time value get from time picker. and database has wrkingtime as time datatype.. here the problem is... Time picker gives(hh:mm + meridian) database -store data format is (hh:mm:ss) when i enter 4:30PM ----> it stored on database is 00:00:04 plz anyone help me
0
8876
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8784
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8556
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8642
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7387
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5666
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4198
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
2011
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1777
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.