Try wrapping $_POST into curly brakets within the query strinh like {$_POST'l_name'}.
1 Putting the $_POST variables into the query like that is a massive vulnerability. That needs fixing first php. Net/manual/en/security.database.
Sql-injection. Php – Pekka Nov 1 at 11:22 I know that. This code was just a test for a guy, using such code in production environment just doesn't make sense.
Using DbSimple or a similar library, as well as ORM libraries is the best scenario. – Paul Selitskas Nov 1 at 11:28 Well, using an ORM is maybe a bit of an overkill :) Properly escaping the data should be enough. Just as a side note - it's really dangerous to show unsafe code on Stack Overflow, hence the down vote.
Somebody, somewhere, with the same problem will find this, think it's the solution and copy & paste it into their project without looking twice. (And I don't think using curly brackets solves the issue either - $_POSTl_name should work) – Pekka Nov 1 at 11:32 1 Oh, it's reasonable. Thank you for the advice ;) – Paul Selitskas Nov 1 at 12:29.
I'm newbie in php but try this code , sure this will help. If($_SERVER'REQUEST_METHOD' == 'POST'){ $f_name = $_POST'f_name'; $l_name = $_POST'l_name'; $password = $_POST'password'; $email_id = $_POST'email_id'; $phone_no = $_POST'phone_no'; $dob = $_POST'dob'; $semester = $_POST'semester'; $department = $_POST'department'; $collage = $_POST'college'; $con = mysql_connect("localhost","root",""); mysql_select_db("portal", $con) or die(mysql_error()); $sql = "INSERT INTO user(f_name,l_name,password,email_id,phone_no,dob,semester,department,college) VALUES ('$f_name','$l_name','$password'','$email_id','$phone_no','$dob','$semester','$department','$college')"; $res = mysql_query($sql,$con); echo "Successfully Signed Up"; mysql_close($con); }?
This is as bad as the original code: it has no error checking, and a SQL injection vulnerability. Php. Net/manual/en/security.database.
Sql-injection. Php – Pekka Nov 1 at 12:30.
Your problem is probably some of your values are null and you mysql table is not accepting null. Can you make sure you are getting a value from the $_POST. To do this set a default value for everything you want to insert in the table for example: $f_name = isset($_POST'f_name')?
$_POST'f_name' : 'my_first_name'; do these for all values.
If you upload it, we can have a look. And indeed, try to secure your SQL! Don't you have any error messages?
Is auto_increment set in your database to automatically insert your primary key? BTW, what's the bracket after $password for? (Just curious, I don't expect it to be a typo :D).
Real escape your POST variables!. Check your $con settings to the database. Double check that the names of your inputs in your form are the same as the $_POSTS that you are placing in your query.
Real escape your POST variables!. " What is that supposed to mean? – NullUserException à° _à° Nov 12 at 17:07.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.