954,585 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Undefined index

I just switched webhosting companies and I'm having a major problem now, I keep getting errors that I wasn't getting before. Mainly, these right here:

Notice: Undefined index: username in D:\hshome\c274056\test.yourroommatefinder.com\register\signup.php on line 12

Here's line 12:

$username = mysqli_real_escape_string($dbc, trim($_POST['username']));

Tried this too:

$username = mysqli_real_escape_string($dbc, trim($_POST['username']));

What could be causing this, I even tried it without the mysql real escape. I have the site up on another server, currently with no problems and i have the error set to show the same.

armyguydave69
Newbie Poster
19 posts since Sep 2009
Reputation Points: 10
Solved Threads: 0
 

The server it is working on probably has notices turned off. You should have an if (isset($_POST['username'])) block around that anyway.

ShawnCplus
Code Monkey
Team Colleague
1,583 posts since Apr 2005
Reputation Points: 526
Solved Threads: 268
 
The server it is working on probably has notices turned off. You should have an if (isset($_POST['username'])) block around that anyway.

Worked like a charm. Thank you.

armyguydave69
Newbie Poster
19 posts since Sep 2009
Reputation Points: 10
Solved Threads: 0
 

actually now I'm having another issue with it, when it returns sticky date (i.e. the form not completely filled out), it returns a 1 for each field. However, if the form is completed it submits the data to to mysql as is?

What should I check, I'm at a complete lost with this. Like I said, I had no issues on the other server so I'm really confused.

armyguydave69
Newbie Poster
19 posts since Sep 2009
Reputation Points: 10
Solved Threads: 0
 

Figured it out, instead of just echoing the defined variable name, I have to use $_POST['variable']; and it works perfect now.

armyguydave69
Newbie Poster
19 posts since Sep 2009
Reputation Points: 10
Solved Threads: 0
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You