Jump to content

Function Help!


Muncey

Recommended Posts

Ok im not new to PHP but i was a beginner and i stopped for a few months to study.. and now it's just totally gone.

 

<form action="" method="post">
<table align="left" border="0" cellspacing="0" cellpadding="3">
<tr><td>Password:</td><td><input type="text" name="pass" maxlength="30"></td></tr>
<tr><td colspan="2" align="left"><input type="submit" name="sublogin" value="Login" onclick="checkpass()"></td></tr>
</table>
</form>
<br /><br />

<?php

function checkpass(){
echo "lol";

if($pass == ""){
echo "<br /><br /><br />Correct!";
} else {
echo "<br /><br /><br />Try Again!";
}
}

?>

 

Basically when i click submit i want it to run the function and then display the echo. This worked when i did it without the function but obviously the pass box is empty when the page is opened so it already displays Correct! so i need it to show the text after the submit button has been pressed.

 

Thanks in advance.

Link to comment
https://forums.phpfreaks.com/topic/51887-function-help/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.