User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 361,628 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,177 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 366 | Replies: 8 | Solved
Reply
Join Date: Mar 2008
Posts: 63
Reputation: sukhy_1 is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 3
sukhy_1 sukhy_1 is offline Offline
Junior Poster in Training

small error when submitting form

  #1  
Mar 28th, 2008
hello ive got a sign in page it works and sends data to database but soon as i had validation code for an email address using java, and then when i click submit it comes up with this error below for every textbox even though all the textboxes have data entered in them this error appears when the form is submitted... any ideas what could be causing this


Notice: Undefined index: StudentName in /home/stud/1/0472547/public_html/Signupcomplete.php on line 49



<form name="f1" method="post" action="Signupcomplete.php" onSubmit="return Validate()" enctype = text/plain>



<p><input type="submit" name="Submit" value="Sign Up"></td>
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Nov 2007
Posts: 86
Reputation: sagedavis is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 6
sagedavis sagedavis is offline Offline
Junior Poster in Training

Re: small error when submitting form

  #2  
Mar 28th, 2008
java or javascript?

It's hard to tell, since you aren't showing us your javascript.... but,...
I would say your "Validate" is somehow over riding everything.
You may be trying to pass the information from these fields via javascript to php, this isn't impossible, it's just tricky...

Your best bet is to force the validate before the submit.. for instance, most people will have to focus on the submit button so, force the running of "validate to happen onFocus of the submit button. This will ensure that if all fields aren't proper, they won't be able to click submit, but, if all is good, it will validate and they will be able to push the button..
Just a guess as I can't see your code.
Sage
Reply With Quote  
Join Date: Nov 2007
Posts: 86
Reputation: sagedavis is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 6
sagedavis sagedavis is offline Offline
Junior Poster in Training

Re: small error when submitting form

  #3  
Mar 29th, 2008
OK, I'm pasting the code you IMd me here, because there are others who may be able to help with this as well.
<script src="signupcheck.js" language="JavaScript" type="text/javascript">
</script>

<Script language = javascript>

function Validate() {
Message = "";

Message = Message + Checkmyusername();

	if (Message == "") {
	return true;
	}
	else {
	alert(Message)
	return false;
	}

}

function Checkmyusername() {
email = document.f1.myusername.value;
AtPos = email.indexOf("@");
StopPos = email.lastIndexOf(".");
Message = "";

	if (email == "") {
	Message = "Not a valid Email address" + "\n";
	return Message;
	}

	if (AtPos == -1 || StopPos == -1) {
	Message = "Not a valid email address" + "\n";
	return Message;
	}

	if (StopPos < AtPos) {
	Message = "Not a valid email address" + "\n";
	return Message;
	}

	if (StopPos - AtPos == 1) {
	Message = "Not a valid email address" + "\n";
	return Message;
	} 

return Message;
}

</script>

<form name="f1" method="post" action="Signupcomplete.php" onSubmit="return Validate()" enctype = text/plain>

<tr>
<td>Fields marked with an asterisk (*) are mandatory</td>
</tr>

<tr><td height=20></td></tr>

<tr>
<td>Your Name*<small> (Enter First and Last Name)</small></td>
<td><input type="text" name="StudentName"></td>
</tr>

<tr>
<td>Email Address*<small> (This will be your User Name)</small></td>
<td><input type="text" name="myusername"></td>
</tr>

<tr>
<td>Type a password*</td>
<td> <input type="password" name="mypassword" maxlength="16" value="" /></td>
</tr> 

<tr>
<td>I accept: <input type="checkbox" value="0" name="agree">
<p><input type="submit" name="Submit" value="Sign Up"></td>
</tr>
</td>
</center>
</table>
</form>
</body>
</html> 

Some ideas here... The function that you really want to call is CheckMyUsername because Validate is not really pushing the information that you want it to, and you can handle everything within the CheckMyUsername function anyway. This, I believe is where your code is breaking.

after each line you need a ";" I have added these in your code above for you. To be honest, this depends on what browser you are using.. IE7 doesn't care about this, but it is still good practice regardless.

I believe (if I am not mistaken) that your variables need to be declared as such... so,
where you have variables you need to type
var foo = "bar";

one thing that you should do after each step run an alert just to see where you are breaking...

I also think you need to put the function call on the button itself and make it an on focus event, or onmousedown that triggers the function call and not onsubmit.

Hope this helps
Sage
Reply With Quote  
Join Date: Mar 2008
Posts: 63
Reputation: sukhy_1 is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 3
sukhy_1 sukhy_1 is offline Offline
Junior Poster in Training

Re: small error when submitting form

  #4  
Mar 29th, 2008
hello still dont work but ive noticed the data still gets input to the database but that notice keeps appearing the only data that dont get entered is the username because its got javascript dont understand what the problem could be...
Reply With Quote  
Join Date: Mar 2008
Posts: 153
Reputation: Suomedia is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 19
Suomedia Suomedia is offline Offline
Junior Poster

Re: small error when submitting form

  #5  
Mar 29th, 2008
The error is in your PHP. You are missing this:


$StudentName = $_POST['StudentName'];


Matti Ressler
Suomedia
If you want your dreams to come true, the first thing you must do is to wake up....
Suomedia - Dynamic Content Management
Reply With Quote  
Join Date: Mar 2008
Posts: 63
Reputation: sukhy_1 is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 3
sukhy_1 sukhy_1 is offline Offline
Junior Poster in Training

Re: small error when submitting form

  #6  
Mar 29th, 2008
but ive got that code in my php, when i take the vaildation off for email everything works, its just when i add that javascript the notices come up cheers
Reply With Quote  
Join Date: Mar 2008
Posts: 153
Reputation: Suomedia is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 19
Suomedia Suomedia is offline Offline
Junior Poster

Re: small error when submitting form

  #7  
Mar 29th, 2008
This is a PHP error, not a javascript error. Your error message tells EXACTLY where the problem is:


Notice: Undefined index: StudentName in /home/stud/1/0472547/public_html/Signupcomplete.php on line 49


Line 49. Please post the code in this file.


Matti Ressler
Suomedia
If you want your dreams to come true, the first thing you must do is to wake up....
Suomedia - Dynamic Content Management
Reply With Quote  
Join Date: Mar 2008
Posts: 63
Reputation: sukhy_1 is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 3
sukhy_1 sukhy_1 is offline Offline
Junior Poster in Training

Re: small error when submitting form

  #8  
Mar 29th, 2008
  1. <?
  2. $sql = sprintf(
  3. "INSERT INTO StudentRecords (StudentName, TelephoneNumber, DOB) ".
  4. "VALUES ('%s','%s','%s')",
  5. mysql_real_escape_string(stripslashes($_REQUEST['StudentName'])),
  6. mysql_real_escape_string(stripslashes($_REQUEST['TelephoneNumber'])),
  7. mysql_real_escape_string(stripslashes($_REQUEST['DOB']))),
  8. $result=mysql_query($sql) or die(mysql_error());
  9.  
  10. $sql= sprintf ("INSERT INTO members (password,username) VALUES ('%s','%s')",
  11. md5(stripslashes($_REQUEST['mypassword'])),
  12. mysql_real_escape_string(stripslashes($_REQUEST['myusername'])));
  13. $result=mysql_query($sql) or die(mysql_error());
  14.  
  15.  
  16. echo "You are now a member safe";mysql_close($con)
  17. ?>
Last edited by peter_budo : Mar 30th, 2008 at 5:14 am. Reason: Keep It Organized - please use [code] tags
Reply With Quote  
Join Date: Mar 2008
Posts: 153
Reputation: Suomedia is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 19
Suomedia Suomedia is offline Offline
Junior Poster

Re: small error when submitting form

  #9  
Mar 29th, 2008
Thats only 17 lines

How about attaching the actual whole file? - Signupcomplete.php


Matti Ressler
Suomedia
If you want your dreams to come true, the first thing you must do is to wake up....
Suomedia - Dynamic Content Management
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb PHP Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the PHP Forum

All times are GMT -4. The time now is 6:40 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC