Jump to content

Recommended Posts

Here is a list of problems in your registration_script.php -

 

1) All of the associative array names ($_POST and $_SESSION) need to be enclosed in quotes so that php does not take ~10 times longer to access each variable by attempting to find a defined constant with the name being used, produce a notice error, then assume you meant a quoted name, then find the actual array index name.

 

2) As has already been pointed out, your INSERT query does not reference a table name.

 

3) You are not validating (what happens or should happen if there is no $_SESSION['id'] or if any of the form fields are empty?) or escaping (to prevent sql injection) the external data being put into the INSERT query.

 

4) INSERT queries don't have WHERE clauses, so the first query on the page will fail due to a SQL syntax error. Are you trying to INSERT a new row or UPDATE an existing row?

 

5) Your queries don't have any error checking, error reporting/error logging, or error recovery logic to get them to tell you when they fail, why they failed, or to take an appropriate action when they fail.

 

6) $PHP_SELF was depreciated almost 8 years ago. You should use $_SERVER['PHP_SELF'] (assuming you want the current URL query string to be carried over when the form is submitted) or you should just use an empty string as the action="" attribute to cause the form to submit to the same page.

 

7) You should use isset($_POST['submit']) to prevent an undefined notice message when the page is requested before the form is submitted.

 

8) You should be developing and debugging php code on a system with error_reporting set to E_ALL and display_errors set to ON in your master php.ini so that php will help you by displaying all the errors it detects. You will save a TON of time. Several of the problems listed would have already been exposed so that you could have found and fixed them yourself.

 

Edit: 9) You are also missing the closing } from the else statement. This would be causing a fatal parse error that would be exposed if error_reporting/display_errors were set as suggested in item #8 in this list.

Link to comment
https://forums.phpfreaks.com/topic/195187-php-script-problem/#findComment-1025890
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.