PHP Forum posting & cookie setting.
Posted: Wed Jul 16, 2008 11:11 am
Hello I am a rather new developer when it comes to server side programming. I am currently learning and testing different methods for creating cookies, however I ran into this issue.
I am trying to submit a form with contact information to a another page called (cookies.php). Here is the forum:
[/size]
I am trying to retrieve the sent information and set them into cookies, here is the code:
[/size]
But for some reason the cookies are not being created, I created a test cookie and it worked fine, any ideas? Or any better ways of doing what I am trying to do.
If you are curious to the practicality of this there is currently none.
I did use the search to find threads remotely close to what I am doing, but so far have found none. I will continue to search.
I am trying to submit a form with contact information to a another page called (cookies.php). Here is the forum:
Code: Select all
<form action="cookies.php" method="POST" name="contactForm">
<h5>Name:: </h5>
<input type="text" name="ct_ctName" id="ct_ctName" class="ct_nameField" size="30"/>
<br/>
<h5>Company:: </h5>
<input type="text" name="ct_ctCompany" id="ct_ctCompany" size="30"/>
<br/>
<h5>Address:: </h5>
<input type="text" name="ct_ctAddress" id="ct_ctAddress" size="30" maxLength="150" />
<br/>
<h5>City:: </h5>
<input type="text" name="ct_ctCity" id="ct_ctCity"size="30" maxLength="50" />
<br/>
<h5>Zip:: </h5>
<input type="text" name="ct_ctZip" id="ct_ctZip" size="30" maxLength="20" />
<br/>
<h5>Phone:: </h5>
<input type="text" name="ct_ctPhone" id="ct_ctPhone" size="30" maxLength="30" />
<br/>
<h5>Email:: </h5>
<input type="text" name="ct_ctEmail" id="ct_ctEmail" size="30" maxLength="75" />
<br/>
<h5>Fax:: </h5>
<input type="text" name="ct_ctFax" id="ct_ctFax" size="30" maxLength="30" />
<br/>
<h5>URL:: </h5>
<input type="text" name="ct_ctURL" id="ct_ctURL" size="30" maxLength="150" />
<br/>
<h5>Subject:: </h5>
<input type="text" name="ct_ctSubject" id="ct_ctSubject" size="30" maxLength="75" />
<br/>
<input type="submit" value="submit" name="submit"/>
I am trying to retrieve the sent information and set them into cookies, here is the code:
Code: Select all
<?php
[color=#0000FF]setcookie[/color]([color=#FF0000]'testtest '[/color],'[color=#FF0000]omg'[/color],time()+60);
//set vars from posts
$ct_Name = [color=#0000FF]$_POST[/color][[color=#FF0000]'ct_ctName'[/color]];
$ct_Company = [color=#0000FF]$_POST[/color][[color=#FF0000]'ct_ctCompany'[/color]];
$ct_Address = [color=#0000FF]$_POST[/color][[color=#FF0000]'ct_ctAddress'[/color]];
$ct_City = [color=#0000FF]$_POST[/color][[color=#FF0000]'ct_ctCity'[/color]];
$ct_State = [color=#0000FF]$_POST[/color][[color=#FF0000]'ct_ctState'[/color]];
$ct_Zip = [color=#0000FF]$_POST[/color][[color=#FF0000]'ct_ctZip'[/color]];
$ct_Phone = [color=#0000FF]$_POST[/color][[color=#FF0000]'ct_ctPhone'[/color]];
$ct_Email = [color=#0000FF]$_POST[/color][[color=#FF0000]'ct_ctEmail'[/color]];
$ct_Fax = [color=#0000FF]$_POST[/color][[color=#FF0000]'ct_ctFax'[/color]];
$ct_URL = [color=#0000FF]$_POST[/color][[color=#FF0000]'ct_ctURL'[/color]];
$ct_Subject = [color=#0000FF]$_POST[/color][[color=#FF0000]'ct_ctSubject'[/color]];
//set cookies from vars from posts
[color=#0000FF]setcookie[/color]([color=#FF0000]'ctName'[/color], $ct_Name, time()+60);
[color=#0000FF]setcookie[/color]([color=#FF0000]'ctCompany'[/color],$ct_Company,time()+60);
[color=#0000FF]setcookie[/color]([color=#FF0000]'ctAddress'[/color],$ct_Address,time()+60);
[color=#0000FF]setcookie[/color]([color=#FF0000]'ctCity'[/color],$ct_City,time()+60);
[color=#0000FF]setcookie[/color]([color=#FF0000]'ctState'[/color],$ct_State,time()+60);
[color=#0000FF]setcookie[/color]([color=#FF0000]'ctZip'[/color],$ct_Zip,time()+60);
[color=#0000FF]setcookie[/color]([color=#FF0000]'ctPhone'[/color],$ct_Phone,time()+60);
[color=#0000FF]setcookie[/color]([color=#FF0000]'ctEmail'[/color],$ct_Email,time()+60);
[color=#0000FF]setcookie[/color]([color=#FF0000]'ctFax'[/color],$ct_Fax,time()+60);
[color=#0000FF]setcookie[/color]([color=#FF0000]'ctURL'[/color],$ct_URL,time()+60);
[color=#0000FF]setcookie[/color]([color=#FF0000]'ctSubject'[/color],$ct_Subject,time()+60);
?>
<html>
<head>
<title>Welcome to my info site.</title>
</head>
<body>
<?php
echo "Thank you";
echo [color=#0000FF]$_COOKIE[/color][[color=#FF0000]'ctName'[/color]];
echo "<br/>";
echo [color=#0000FF]$_COOKIE[/color][[color=#FF0000]'testtest'[/color]];
?>
</body>
</html>But for some reason the cookies are not being created, I created a test cookie and it worked fine, any ideas? Or any better ways of doing what I am trying to do.
If you are curious to the practicality of this there is currently none.
I did use the search to find threads remotely close to what I am doing, but so far have found none. I will continue to search.