I'm trying to put a simple sign for a user sign up. I am using the following PHP code for this.
& lt; Php requires 'connect.php'; 'Variables.php' is required; // set variable $ tbl_name = 'user'; $ Username = $ _POST ['Username']; $ Password = $ _POST ['password']; $ Checkpave = $ _POST ['checkpoint']; $ Email = $ _POST ['email']; $ Dob = $ _POST ['dub']; $ Username = stripslashes ($ username); $ Username = mysqli_real_escape_string ($ conn, $ _POST ['username']); $ Password = strip slash ($ password); $ Password = mysqli_real_escape_string ($ conn, $ _POST ['password']); $ Checkpoint = stripssash ($ checkw); $ Checkpw = mysqli_real_escape_string ($ conn, $ _POST ['checkp']); Function (mmpy) {foreach (as func_get_args () $ arg) if (! $ (Arg)) {continue; } And {header ('location: register.php? Msg = unsuccessful'); }} // Check that the variables are empty i mempty ($ username); Mempty ($ password); Mempty ($ checkpw); Mempty ($ date of birth); If (strcmp ($ password, $ checkpw) == 0} {$ sql = "$$ tbl_name (username, password, email, dob) values ($ US $ username, $ password, $ email, $ dob)" INSERT; If (mysqli_query ($ conn, $ sql)) {Echo "Successfully Registered!"; }}? & Gt; $ _POST comes from an HTML form, where I do not believe the problem exists, but I'll show you this just like that. & lt; Form method = "post" action = "initsec.php" & gt; & Lt; P class = "reg" & gt; Username: & lt; / P & gt; & Lt; Input name = "user name" type = "text" placeholder = "user name" id = "user name" & gt; & Lt; Br / & gt; & Lt ;? Php if (isset ($ _GET ['msg']) & amp; $ _GET ['msg'] == 'PVS') {echo "password does not match! }? & Gt; & Lt; P class = "reg" & gt; Password: & lt; / P & gt; & Lt; Input name = "password" type = "password" placeholder = "password" id = "password" & gt; & Lt; Br / & gt; & Lt; P & gt; Confirm Password: & lt; / P & gt; & Lt; Input type = "password" name = "checkpw" id = "checkpw" placeholder = "re-enter password" & gt; & Lt; Br / & gt; & Lt; P & gt; Email address: & lt; / P & gt; & Lt; Input type = "text" name = "email" id = "email" placeholder = "email address" & gt; & Lt; Br / & gt; & Lt; P & gt; Date of Birth: & lt; / P & gt; & Lt; Input type = "date" name = "dob" id = "dob" & gt; & Lt; Br / & gt; & Lt; Input name = "register" type = "submit" value = "registration" category = "register" & gt; & Lt; / Form & gt;
The problem is that the record is not being included.
Some issues I think your main one is your SQL statement:
"$ Tbl_name" (user name, password, email, dob) values ($ $ username, $ password, $ email, $ dob) / code>
string values will probably have to be cited (as That notes are noted by @fred-ii-):
"$ tbl_name INSERT (username, password, email, dub) VALUES ('$ username', '$ password' , '$ Email', '$ dob') "
I also do not think this funk Shan is going to work as you expect it to be:
function memory (foreach (func_get_args () as $ arg) {if (! (Below ($ Arg)) and {header ('location: register.php? Msg = unsuccessful');}}}
I surrounded the foreach
Add curly braces, I suggest that you do this easily for readability. Also, if you leave exit
to headers ()
after explicitly redirecting If not, then the script Continuation ( because of all your failures to try to be inserted into the database), so I will also suggest that you do so. Since you can continue
in the loop, you can terminate it altogether:
function memory () {foreach (func_get_args () $ arg As) {If (empty ($ arg)) {continue; } Header ('location: register.php? Mess = unsuccessful'); Go out(); }}
Since you are using func_get_args
in the function, you can exceed any number of arguments, from which you are calling the function Can reduce the number of:
mempi ($ username, $ password, $ checkpay, $ dob);
No comments:
Post a Comment