FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


I havent got my account handled nor tested this code...





TheMasterCheaif
But i was wondering if this code is correct that i thought of making

Code:

<html>
<head></head>
<body>
Password
<input type="text" name="psw" size="5" maxlength="9">
<input type="submit" name="sumbmit" value="log in">
</body>
</html>

filename.php
Code:

<html>
<head></head>
<body>
<?php
//password varible
$password= whateverpasswordis
//check to see if password is right
if ($_POST['psw'] == $password){
echo 'You craked the code';}
else {
echo 'errr wrong code try agin';}
?>
</body>
</html>


Is this code correct and usable?


and i also need to know if there is a code to send the user to a certain page if a varible is equal to another varible. Question Question
TheMasterCheaif
Ok 21 veiws and no anser coud i please get an anser here
[FuN]goku
well i see maybe 1 or 2 things.. i would set it like this just cuz im a neat freak in my code sometimes. Wink

Code:

<html>
<head></head>
<body>
<?php

$password = 'whateverpasswordis';
$submitted = $_POST['psw'];

if ($submitted == $password){

echo 'You craked the code';

}else{

echo 'errr wrong code try agin';
}
?>
</body>
</html>
TheMasterCheaif
That was just a rouph code that i wrote ou and yes i dont like my codes bunched together but does the code work?
[FuN]goku
the bit i just did should work. i cant test it cuz im rather busy with php scripting of my own atm.
TheMasterCheaif
ahh i just had to resumbit my account thx that means my first php code worked Very Happy
hexkid
TheMasterCheaif wrote:
Code:

<html>
<head></head>
<body>
Password
<input type="text" name="psw" size="5" maxlength="9">
<input type="submit" name="sumbmit" value="log in">
</body>
</html>
Invalid HTML. You are missing a title inside the <head>; the input tags must be inside a form.

TheMasterCheaif wrote:
filename.php
Code:

<html>
<head></head>
<body>
<?php
//password varible
$password= whateverpasswordis
//check to see if password is right
if ($_POST['psw'] == $password){
echo 'You craked the code';}
else {
echo 'errr wrong code try agin';}
?>
</body>
</html>

You are missing a semicolon between "whateverpasswordis" and "if".
Also I would delimit whateverpasswordis with quotes or single quotes ("or '), unless, of course, it really is a constant defined elsewehere in your code.


TheMasterCheaif wrote:
and i also need to know if there is a code to send the user to a certain page if a varible is equal to another varible. Question Question
Look up header() in the fine PHP manual.
Diablosblizz
Also, if the two codes are on different pages don't you need to add the form function:

Code:
<form name="anyname" method="post" action="filename.php">


Thats only if the two codes are on seperate pages, cause how is the form suspossed to tell you where to go.
TheMasterCheaif
I thought of the form code, but I wasent really sure what it was. Thanks for clearing that up.

And yes I knew I needed something in the head. but this is a rouph code.

so it shoud be
Code:

$password= 'whateverpasswordis'
hexkid
TheMasterCheaif wrote:
so it shoud be
Code:

$password= 'whateverpasswordis'
Don't forget the semicolon!

Usually people place it right after the statement, but you can put it anywhere between this statement and the next
Code:
$password= 'whateverpasswordis';

$password= 'whateverpasswordis'
; if (true) { /* void */ }

$password= 'whateverpasswordis'
// comment
;
if (true) { /* void */ }
TheMasterCheaif
SO it be

Code:

$password= 'whateverpasswordis' ;



and is there a way to put php and html in one file?
hexkid
TheMasterCheaif wrote:
is there a way to put php and html in one file?

Yes. Make sure your files have a ".php" extension.
Code:
<html>
<head>
<title>THIS IS HTML</title>
</head>
<body>
<?php
echo '<p>AND THIS IS PHP.</p>';
echo '<p>current server time is ', date('Y-m-d H:i:s'), '</p>';
?>
</body>
</html>
TheMasterCheaif
Thank you so much hexkid, you shoud be an admin, or atleast a mod your one of the most helpful users on frihost.
manum
your forms code should be

<html>
<head></head>
<body>
<form action = "yourscript.php" method = "POST">
Password
<input type="text" name="psw" size="5" maxlength="9">
<input type="submit" name="sumbmit" value="log in">
</form>
</body>
</html>


and now it will work
manum
and the php code should be

<html>
<head></head>
<body>
<?php
//password varible
$password= "whateverpasswordis";
//check to see if password is right
if ($_POST['psw'] == $password){
echo ("You craked the code");}
else {
echo ("errr wrong code try agin");}
?>
</body>
</html>
Related topics
How did you hear about FRIHost ?
Win Xp Tip (Tried And Tested)
A few simple questions about Frihost
Points.
How much time does it take to get my account ready?
Just got account
showing off the code I just made and ask for suggestions
Successful Adsense Tip - Start Earning
What a nice sitebuilder!!
New way to test time travel
full flash website help
Tony Blair
Jeremy Clarkson loses 500 Pounds
To Upgrade or Not to Upgrade?
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.