473,326 Members | 2,173 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

$_POST not working

Hi all, please to meet you!

Im having a problem getting post variables from a form. Here is the form:

Expand|Select|Wrap|Line Numbers
  1. <a href='register_form.php'>Not a member?</a>
  2.   <form method='post' action='member.php'>
  3.   <table bgcolor='#cccccc'>
  4.    <tr>
  5.      <td colspan=2>Members log in here:</td>
  6.    <tr>
  7.      <td>Username:</td>
  8.      <td><input type='text' name='username'></td></tr>
  9.    <tr>
  10.      <td>Password:</td>
  11.      <td><input type='password' name='passwd'></td></tr>
  12.    <tr>
  13.      <td colspan=2 align='center'>
  14.      <input type='submit' value='Log in'></td></tr>
  15.    <tr>
  16.      <td colspan=2><a href='forgot_form.php'>Forgot your password?</a></td>
  17.    </tr>
  18.  </table></form>


Here's the PHP fragment....


Expand|Select|Wrap|Line Numbers
  1. <?php
  2.  
  3.     //include function files for this application
  4.     require_once('bookmark_fns.php');
  5.     session_start();
  6.  
  7. /*    if (!isset($_POST['username'])) {
  8.       echo "Uhoh, you need to fill out the whole  form!";
  9.       exit;
  10.     } 
  11. */
  12.  
  13.     //create short varible names
  14.     $username = $_POST['username'];
  15.     $passwd = $_POST['passwd'];
When I run the script I get....



Notice: Undefined index: username in C:\wamp\www\Bobs\26\member.php on line 13

Notice: Undefined index: passwd in C:\wamp\www\Bobs\26\member.php on line 14

Oddly enough, apart from that the script runs perfectly! What am I doing wrong? Thanks!


PS On other forums it reccomends surpressing notices. Ive always thought that this is NOT the way forward! :D
Jul 13 '10 #1

✓ answered by dlite922

if you want to find out what is in a variable, use var_dump()

In this case do a var_dump($_POST) and see what's inside it.

The error just means it doesn't know any items in the post array or 'username' and 'passwd'

You should fix all errors and notices in your PHP, but suppress them in a production environment.


Dan

3 1254
dlite922
1,584 Expert 1GB
if you want to find out what is in a variable, use var_dump()

In this case do a var_dump($_POST) and see what's inside it.

The error just means it doesn't know any items in the post array or 'username' and 'passwd'

You should fix all errors and notices in your PHP, but suppress them in a production environment.


Dan
Jul 13 '10 #2
Dormilich
8,658 Expert Mod 8TB
PS On other forums it reccomends surpressing notices. Ive always thought that this is NOT the way forward! :D
this is indeed a recommendation, though not in general, but for productivity servers. for development servers it is a mistake to disable any error level.
Jul 13 '10 #3
thanks for the word-up on the errors question. Used var_dump and discovered that the form works perfectly. It is a separtate link to member.php on another page that was causing the problem. Many thanks again!
Jul 13 '10 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

8
by: Hardy Wang | last post by:
Hi: Is it possible for me to create/open web application from remote machine other than port 80? And create application directly under virtual web site instead of creating a virtual directory?...
5
by: tshad | last post by:
I have been working with setting my drop boxes to allow double clicking to select an item. It worked fine until I made some changes. I then stripped the page down to the bare essentials to find...
6
by: Matt Frame | last post by:
I have a client that has asked us to get a digital signature certificate and start digitally signing all files we pass between each other. I have heard of the subject and know about the certs but...
0
by: CFloyd | last post by:
I have a web service client that sends an XML string to the web service for processing. I alos have to add some headers to the post. I first establish the baseuri as === baseuri = new...
0
by: CFloyd | last post by:
I have a web service client that sends an XML string to the web service for processing. I alos have to add some headers to the post. I first establish the baseuri as === baseuri = new...
1
by: logik3x | last post by:
I'm developping a program to automate the submisson of grades to a website called omnivox.ca (http://brebeuf.omnivox.ca). My problem is that I can't get the login working. I get the cookie right...
24
by: moriman | last post by:
Hi, The script below *used* to work. I have only just set up a server, PHP etc again on my Win98 system and now it doesn't? On first loading this page, you would have $p = and the button...
4
by: qbproger | last post by:
I'm developing a plugin for some software. The previous version of the software didn't require a start in directory to be set. This allowed me to leave the working directory to the default in the...
11
by: =?Utf-8?B?QkxVRVNUQVI=?= | last post by:
Here is the link of the website http://www.smartcharlotte2050.com/YourThoughts.asp I have been told to change only the form action part of this site.which is to "response.asp" Here the method...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.