Welcome to HBH! If you have tried to register and didn't get a verification email, please using the following link to resend the verification email.

ghost's Avatar
0 0

ok I am going to show you this script that is from my site and the issue that I am having is the fact that when you go to the site and hit enter it actuially shows you its own source

<form> <form action="home.php" method="GET"> <b>Username:</b><input type="text" name="username" id="username" /> <b>password:</b><input type="password" name="password" id="password" /> <input type="submit" value="submit" id="submit" /> </form> <?php if ($_GET['username'] == "krystal" && $_GET['password'] =="vineland") { setcookie("krystal", "krystal", time()+3600); } ?>

<?php if (isset($_COOKIE["krystal"])) echo "Welcome " . $_COOKIE["krystal"] . "!<br />"; else echo "Welcome guest!<br />"; ?>


ghost's Avatar
0 0

Is your webserver set up correctly to execute PHP?

Also, you might wanna look at using sessions for that kind of login, and using POST instead of GET for logins. Basing your authentication solely on whether a cookie is set is bad.


ghost's Avatar
0 0

Is the extension of the file .php?


ghost's Avatar
0 0

Mephisto wrote: Is the extension of the file .php?

And is it called home.php?


ghost's Avatar
0 0

mastergamer wrote: Is your webserver set up correctly to execute PHP?

Also, you might wanna look at using sessions for that kind of login, and using POST instead of GET for logins. Basing your authentication solely on whether a cookie is set is bad.

the php is executing fine the only issue i am having now is the fact that it is showing the source code.


ghost's Avatar
0 0

vinelander wrote: the php is executing fine the only issue i am having now is the fact that it is showing the source code.

The PHP wouldn't be executing correctly if it is viewable in the source code.


ghost's Avatar
0 0

try

if ($_GET[&#39;username&#39;] == &quot;krystal&quot; && $_GET[&#39;password&#39;] ==&quot;vineland&quot;)
{
setcookie(&quot;krystal&quot;, &quot;krystal&quot;, time()+3600);
}
?&gt;
&lt;form action=&quot;home.php&quot; method=&quot;GET&quot;&gt;
&lt;b&gt;Username:&lt;/b&gt;&lt;input type=&quot;text&quot; name=&quot;username&quot; id=&quot;username&quot; /&gt;
&lt;b&gt;password:&lt;/b&gt;&lt;input type=&quot;password&quot; name=&quot;password&quot; id=&quot;password&quot; /&gt;
&lt;input type=&quot;submit&quot; value=&quot;submit&quot; id=&quot;submit&quot; /&gt;
&lt;/form&gt;


&lt;?php
if (isset($_COOKIE[&#39;krystal&#39;]))
echo &quot;Welcome &quot; . $_COOKIE[&#39;krystal&#39;] . &quot;!&lt;br /&gt;&quot;;
else
echo &quot;Welcome guest!&lt;br /&gt;&quot;;
?&gt;```

ghost's Avatar
0 0

Just make sure it executes properly - make a page called test.php and put

&lt;? echo &quot;testing&quot;; ?&gt;

as the source. If it doesn't show only the text testing, it isn't executing properly. If it's not executing properly, you need a new host, for example, the one in my sig (yes, it's free).


fashizzlepop's Avatar
Member
0 0

Possibly you are using Notepad?

When you save in notepad it auto saves as a .txt

So if you put the name index.php it will save as index.php.txt and you will see the source code.

So make sure that under FILE TYPE it says "All files" not " Text file *.txt"

That might be your problem.