Closed Thread Icon

Topic awaiting preservation: checking if the submit button was clicked..? Pages that link to <a href="http://ozoneasylum.com/backlink?for=23540" title="Pages that link to Topic awaiting preservation: checking if the submit button was clicked..?" rel="nofollow" >Topic awaiting preservation: checking if the submit button was clicked..?\

 
Author Thread
Fikzy
Nervous Wreck (II) Inmate

From:
Insane since: Aug 2004

posted posted 10-04-2004 18:27

T.W.I.M.C,
Plese, Acess the code Below:
File Name = C:\Dev\php\practice.php

code:
<html>
<head>
<title>PHP Practice::I Am Getting Bata!</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>

<h3>Testing things stored in Session
<form action="practice.php" method="post" name="testForm">
UserName<input name="name" type="text"><br>
Password<input name="pword" type="password">
<br>
<input name="submit" type="submit" value="Submit">
</form>

<?php
if($_POST['submit']){
$name = $_POST['name'];
$password = $_POST['pword'];
}
print"$name<br>";
print"$password";
?>
</h3>
</body>
</html>


What I intended to do with this code was to collect the values on the form fields and print it right under the form on the same page.. only when the submit button is clicked. my litle code works fine.. but when ever i load the page for the first time, i get the following errors:

Notice: Undefined index: submit in C:\Dev\php\practice.php on line 18

Notice: Undefined variable: name in C:\Dev\php\practice.php on line 22

Notice: Undefined variable: password in C:\Dev\php\practice.php on line 23

..after which when i click the submit button, the error goes and what ever i have in the fields are printed.
I know the reason for the error is because there are no values yet in the submit, name, pword varables. I need to know how I can do such validation without having to see the

quote:
Undefined index

error when i load my page for the first time.

-Fikayo

(Edited by Fikzy on 10-04-2004 18:30)

Tyberius Prime
Paranoid (IV) Mad Scientist with Finglongers

From: Germany
Insane since: Sep 2001

posted posted 10-04-2004 18:51

php->isset()

Fikzy
Nervous Wreck (II) Inmate

From:
Insane since: Aug 2004

posted posted 10-05-2004 11:51

THANKS,
isset() just works fine for me.. i did something like.

code:
if (isset($_POST['submit'])) {
$name = $_POST['name'];
$password = $_POST['pword'];
print"$name<br>";
print"$password";
}



you wont believe how many other things i was able to learn from http://www.php.net/manual/en/

... I wonder what somebody like me would do without a forum like OzoneAsylum, without people like Tyberius Prime in it!

Thanks.
-Fikayo

Fikzy
Nervous Wreck (II) Inmate

From:
Insane since: Aug 2004

posted posted 10-05-2004 12:17

THANKS,
isset() just works fine for me.. i did something like.

code:
if (isset($_POST['submit'])) {
$name = $_POST['name'];
$password = $_POST['pword'];
print"$name<br>";
print"$password";
}



you wont believe how many other things i was able to learn from http://www.php.net/manual/en/

... I wonder what somebody like me would do without a forum like OzoneAsylum, without people like Tyberius Prime in it!

Thanks.
-Fikayo

DmS
Maniac (V) Inmate

From: Sthlm, Sweden
Insane since: Oct 2000

posted posted 10-05-2004 20:36

learn from the manual perhaps
(sorry, couldn't resist)

I agree, this place is one of the rare remaining goldmines on the net.
/Dan

{cell 260} {Blog}
-{ “Computer games don’t affect kids; I mean if Pac-Man affected us as kids, we’d all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music.” (Kristian Wilson, Nintendo, Inc, 1989.) }-

Fikzy
Nervous Wreck (II) Inmate

From:
Insane since: Aug 2004

posted posted 10-06-2004 15:35

Howsh!
I never even got to know there was a MANUAL until i GOT HERE!
i.e php->isset() gave me the discovery!


-Fikzy!

« BackwardsOnwards »

Show Forum Drop Down Menu