Hack Forums
[PHP] User Registration - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151)
+---- Forum: Web Development (https://hackforums.net/forumdisplay.php?fid=183)
+---- Thread: [PHP] User Registration (/showthread.php?tid=5471012)



User Registration - Disparity - Nov 21, 2016

EDIT: Since I had to use [ paste ] and can't change anything, it's worth noting I've fixed lines 25 and 19.

So I'm working on a user registration/login system and I can't seem to find where I've messed up with the registration here:

register_action.php


connection.php


register.html
Code
<html>
    <head>
    </head>
    <body>
        <form action="register_action.php" method="post" id="form">
        <br>
        <p>Username:<input type="text" name="user" class="user"></p>
        <p>Pass:</p> <input type="text" name="pwd" class="pwd">
        Email: <input type="text" name="email" class="email">
            <br>
        
        <div align="center"><input type="submit" value="insert" form="form"></div>
        </form>
            <br>

    </div>

    </body>
</html>

From what I can see everything should work alright, but it doesn't so clearly something's wrong. Thanks.


* - PartTimeNinja - Nov 21, 2016

PHP Code

<?php 
$stmt
->execute; 

->

PHP Code

<?php 
$stmt
->execute(); 

That will probably do the trick.


* - Disparity - Nov 21, 2016

(Nov 21, 2016 06:16 PM)PartTimeNinja Wrote:  
PHP Code

<?php 
$stmt
->execute; 

->

PHP Code

<?php 
$stmt
->execute(); 

That will probably do the trick.

Still not working unfortunately.


* - Mr.Steven - Nov 21, 2016

Assuming you fixed lines 19 and 25 as you said, the only line you need to fix is line 23, a semicolon is missing at the end of the line.

If you fixed these three, it should work. (if it doesn't work, make sure both database and table have the name "userdata" as stated in the scripts)


* - Disparity - Nov 21, 2016

(Nov 21, 2016 06:40 PM)Mr.Steven Wrote:  Assuming you fixed lines 19 and 25 as you said, the only line you need to fix is line 23, a semicolon is missing at the end of the line.

If you fixed these three, it should work. (if it doesn't work, make sure both database and table have the name "userdata" as stated in the scripts)

Thanks loads, though it's still not quite working.

Database name is forum_users now and updated connection.php accordingly, and the table is userdata.

Is there something wrong with my PDO statement or something maybe?


* - Mr.Steven - Nov 21, 2016

(Nov 21, 2016 06:50 PM)Disparity Wrote:  Thanks loads, though it's still not quite working.

Database name is forum_users now and updated connection.php accordingly, and the table is userdata.

Is there something wrong with my PDO statement or something maybe?
Are you getting any errors?

If not, insert these lines on top of register_action.php and try again.
PHP Code

<?php 
ini_set
('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL); 

I tested your script and it worked just fine after fixing these 3 lines.


* - Disparity - Nov 21, 2016

(Nov 21, 2016 06:52 PM)Mr.Steven Wrote:  Are you getting any errors?

If not, insert these lines on top of register_action.php and try again.
PHP Code

<?php 
ini_set
('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL); 

I tested your script and it worked just fine after fixing these 3 lines.

Didn't have errors enabled. Added that and realized for whatever reason FileZilla failed to upload a fixed version of connection.php. Thanks!


* - FeatureBug - Nov 22, 2016

What webhosts manage to install PHP and not have errors turned on by default?? I suppose once it's online, errors should be turned off, but even then it should be a conscious decision to turn them off. Hosts shouldn't assume the server is for production and not for development (or both)


* - Strider64 - Nov 22, 2016

I have been doing this in my utilities.inc.php file that I put at the top of every php page ->

PHP Code

<?php 
/* Turn on error reporting */
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
if (
filter_input(INPUT_SERVER, 'SERVER_NAME', FILTER_SANITIZE_URL) == "localhost") {
    
error_reporting(-1); // -1 = on || 0 = off
} else {
    
error_reporting(0); // -1 = on || 0 = off
} 

that way I don't have to worry local or remote server.


* - Disparity - Nov 22, 2016

(Nov 22, 2016 01:54 AM)FeatureBug Wrote:  What webhosts manage to install PHP and not have errors turned on by default?? I suppose once it's online, errors should be turned off, but even then it should be a conscious decision to turn them off. Hosts shouldn't assume the server is for production and not for development (or both)

I'm using my personal VPS for this to get a feel of Linux servers and how webservers work, and I never thought to enable them. 😊


* - RumbleFrog - Nov 23, 2016

Fyi: you can edit paste :P, just paste it under your own account and not guest.


* - Disparity - Nov 23, 2016

(Nov 23, 2016 04:14 AM)RumbleFrog Wrote:  Fyi: you can edit paste :P, just paste it under your own account and not guest.

Don't have an account and can't be bothered to make one. 😝


* - throwAway445 - Nov 26, 2016

you'll want to sanitise the email variable too, especially if you're storing it later. the password is being hashed so that's fine