Strange value for date
Hi Ben
Need you help and awesome coding skills again
Went to implement the auto date that you explained so well in a previous post.
Signup api page code
<html>
<head>
<meta http-equiv="Content-Type"
content="text/html; charset=utf-8">
<title>API Signup</title>
</head>
<body>
<img style="width: 728px; height: 90px;" alt="banner"
src="banner-signup.png"><br>
<form action="subscribe.php" method="post"
accept-charset="utf-8">
<br>
This will Subscribe you to the API test List<br>
<br>
<label for="name">Name</label>
<input name="name" type="text"><br>
<label for="email">Email</label>
<input name="email" type="text"><br>
<label for="Test">Test</label>
<input name="Test" type="text"><br>
<br>
<input name="Date" id="Date"
value="<?php echo strftime('%b %d, %G', time());?>"
type="hidden">
<input name="Subscribe" type="submit"></form>
</body>
</html>
code in the subscribe.php file
//POST variables
$name = $_POST['name'];
$email = $_POST['email'];
$Test = $_POST['Test'];
$Date = $_POST['Date'];
$boolean = 'true';
//Check fields
if($name=='' || $email=='' || $Test=='')
{
echo 'Please fill in all fields.';
exit;
}
//Subscribe
$postdata = http_build_query(
array(
'name' => $name,
'email' => $email,
'list' => $list,
'Test' => $Test,
'Date' => $Date,
'boolean' => 'true'
)
);
$opts = array('http' => array('method' => 'POST', 'header' => 'Content-type: application/x-www-form-urlencoded', 'content' => $postdata));
$context = stream_context_create($opts);
$result = file_get_contents($your_installation_url.'/subscribe', false, $context);
//check result and redirect
if($result)
header("Location: $success_url");
else
header("Location: $fail_url");
?>
Sendy is installed on Hostmonster server
When I export the cvs for the list it gives
test-b testb@test.com vanilla Dec 31 1969
Did I screw up the code, or is the server date wrong, why didn't I get Feb 16 2013
Thanks
Craig
Comments
Hi @CraigC,
What is the date format POSTed (
$Date = $_POST['Date'];) into the PHP script?Thanks.
Ben
Hi Ben
Sign up page http://www.craigchitty.com/Sendy/API_signup.html
used your example " type="hidden">
from http://sendy.co/discussion/560/how-do-i-set-the-date-custom-field-to-be-hidden-and-automatically-populate-in-subscriber-forms/p1
were did I go wrong?
Craig
lets try that without the < > and see if it posts
input name="Date" id="Date"
value="<?php echo strftime('%b %d, %G', time());?>"
type="hidden"
Hi @CraigC,
Here's the problem, you included
<?php echo strftime('%b %d, %G', time());?>in yourAPI_signup.htmlfile.API_signup.htmlis a HTML file (not PHP), hence it cannot parse this PHP code<?php echo strftime('%b %d, %G', time());?>.You need to change the extension of your
API_signup.htmltoAPI_signup.php. Then visit the subscribe page at http://www.craigchitty.com/Sendy/API_signup.php.Ben
Well as Jamie would say "there's your problem"
Works perfectly now
Thanks
Craig