•
•
•
•
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
![]() |
•
•
Join Date: Mar 2008
Posts: 63
Reputation:
Rep Power: 1
Solved Threads: 3
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>
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>
•
•
Join Date: Nov 2007
Posts: 86
Reputation:
Rep Power: 1
Solved Threads: 6
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
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
•
•
Join Date: Nov 2007
Posts: 86
Reputation:
Rep Power: 1
Solved Threads: 6
OK, I'm pasting the code you IMd me here, because there are others who may be able to help with this as well.
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
<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
•
•
Join Date: Mar 2008
Posts: 153
Reputation:
Rep Power: 1
Solved Threads: 19
The error is in your PHP. You are missing this:
Matti Ressler
Suomedia
$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
Suomedia - Dynamic Content Management
•
•
Join Date: Mar 2008
Posts: 153
Reputation:
Rep Power: 1
Solved Threads: 19
This is a PHP error, not a javascript error. Your error message tells EXACTLY where the problem is:
Line 49. Please post the code in this file.
Matti Ressler
Suomedia
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
Suomedia - Dynamic Content Management
•
•
Join Date: Mar 2008
Posts: 63
Reputation:
Rep Power: 1
Solved Threads: 3
php Syntax (Toggle Plain Text)
<? $sql = sprintf( "INSERT INTO StudentRecords (StudentName, TelephoneNumber, DOB) ". "VALUES ('%s','%s','%s')", mysql_real_escape_string(stripslashes($_REQUEST['StudentName'])), mysql_real_escape_string(stripslashes($_REQUEST['TelephoneNumber'])), mysql_real_escape_string(stripslashes($_REQUEST['DOB']))), $result=mysql_query($sql) or die(mysql_error()); $sql= sprintf ("INSERT INTO members (password,username) VALUES ('%s','%s')", md5(stripslashes($_REQUEST['mypassword'])), mysql_real_escape_string(stripslashes($_REQUEST['myusername']))); $result=mysql_query($sql) or die(mysql_error()); echo "You are now a member safe";mysql_close($con) ?>
Last edited by peter_budo : Mar 30th, 2008 at 5:14 am. Reason: Keep It Organized - please use [code] tags
•
•
Join Date: Mar 2008
Posts: 153
Reputation:
Rep Power: 1
Solved Threads: 19
Thats only 17 lines
How about attaching the actual whole file? - Signupcomplete.php
Matti Ressler
Suomedia
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
Suomedia - Dynamic Content Management
![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
•
•
•
•
DaniWeb PHP Marketplace
- Perl/CGI (Reading Data) Part II (Computer Science and Software Design)
- Form not sending email (PHP)
Other Threads in the PHP Forum
- Previous Thread: MS Access ....
- Next Thread: How can I hyperlink an image ?


Linear Mode