469,326 Members | 1,537 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,326 developers. It's quick & easy.

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

<?php
include 'connection.php';
if(isset($_POST['submit']))
{
$name1=$_POST['name'];
$email1=$_POST['email'];
$re_email1=$_POST['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,pass2,phone,ustate,cit y,street,pin) VALUES ('$name1','$email1','$re_email1','$npass1','$npass 2','$phone1','$state1','$city1','$street1','$pin1' )";
// $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."')";
$result=mysqli_query($conn,$sql);
if($result)
{
echo "<br>User has been registered";
header('Location: mainpage.php');
exit;
}
else{
echo "Error:".$sql.":-".mysqli_error($conn);
}
mysqli_close($conn);
}
?>
<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.length < "6") || (signupform.pass1.value.length <"6") ||(signupform.pass.value > "8")||(signupform.pass1.value > "8")){
alert("!! Invalid Password. Enter Password with 6-8 characters !!");
pass.focus();
pass2.focus();
return false;
}
if(signupform.pass.value != signupform.pass1.value){
alert("! Both the passwords does not match !");
pass.focus();
pass1.focus();
return false;
}

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

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

// window.location.href="login.html";
alert("User has been successfully Registered");
true;
}
</script>
</head>
<body>
<div class="topnavigation">
<img id="carlogo" src="images/download.jfif" alt="Avatar">
<span id="company_name">CLASSICS CUSTOMS</span>
</div>
<div class="register" >
<div class="signup">
<form name="signupform" method="POST" onsubmit="return check()" action="mainpage.php">
<center><b><h2 style="color: white;">Enter your Details to SignUp</h2></b></center>
<label>Name :</label><input type="text" name="name" id="name" placeholder="Enter Full Name" required><br><br>
<label>Email :</label><input type="email" name="email" id="email" placeholder="Enter Email" required><br><br>
<label>Confirm Email :</label><input type="email" name="email1" id="email1" placeholder="Re-enter Email" required><br><br>
<label>Password :<label><input type="password" name="pass" id="pass" placeholder="Enter Password of maximum 10 digits"required ><br><br>
<label>Confirm 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="Enter 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="Karnataka">Karnataka</option>
<option value="Andhra Pradesh">Andhra Pradesh</option>
<option value="Goa">Goa</option>
<option value="Maharastra">Maharastra</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="Enter your city"><br><br>
<label>Street/Address :</label><textarea type="text" name="street" id="street" placeholder="Enter your street"></textarea><br><br>
<label>PinCode :</label><input type="number" name="pin" id="pin" placeholder="Enter your PinCode"><br><br>
<center><button class="button" name="submit">SignUp</button></center>
<!-- <center><input*type="submit"*class="button"*name=" submit"*value="Signup"></center> -->
</form>
</div>
</div>

</body>
</html>

<!-- pattern="^\d{6}$" -->
Sep 17 '21 #1
1 3426
dev7060
504 Expert 256MB
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

Post your reply

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

Similar topics

1 post views Thread by garimapuri | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
reply views Thread by harlem98 | last post: by
reply views Thread by listenups61195 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.