set cookie php what am i doing wrong.?

Crackruckles

New member
I am trying to save some user data into cookies using php, i have follow a few tutorials online and i always get the same problem, the first php page with has the form works perfectly and sends the data using get or put to the second page but then all that is displayed is the actual code in the php file.

PHP set cokkies file:
<?php
$expire=time()+60*60*24*30;
setcookie("host", $_GET["element_1"], $expire);
setcookie("port", $_GET["element_2"], $expire);
setcookie("pass", $_GET["element_3"], $expire);
header('Location: stats.php');
?>

PHP Form File:
<form id="form_293945" class="appnitro" action="set_cookie.php" method="GET" >
<div class="form_description">
<h2>Server Details</h2>
<p></p>
</div>
<ul >
<li id="li_1" >
<label class="description" for="element_1">Hostname or IP </label>
<div>
<input id="element_1" name="element_1" class="element text medium" type="text" maxlength="255" value=""/>
</div>
</li>
<li id="li_2" >
<label class="description" for="element_2">Port Number </label>
<div>
<input id="element_2" name="element_2" class="element text medium" type="text" maxlength="255" value=""/>
</div>
</li>
<li id="li_3" >
<label class="description" for="element_3">Status Password If Set </label>
<div>
<input id="element_3" name="element_3" class="element text medium" type="text" maxlength="255" value=""/>
</div>
</li>
<li class="buttons">
<input type="hidden" name="form_id" value="293945" />
<input id="saveForm" class="button_text" type="submit" name="submit" value="Save" />
</li>
</ul>
</form>
 
Back
Top