PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Below is the code for post.php a processing part of the form. To whatever i post i get a blank page for post.php when testing on server.
Parse error: parse error in c:\program files\easyphp1-8\www\valid\post.php on line 34
CURRENTLY VALIDATING FOR NAME AND SECCODE ONLY, rest are dummy in index.php
POST.PHP
<?php
require_once('../../includes/clean.inc.php');
session_start();
if (!isset($_SESSION['token']))
{
session_regenerate_id();
$_SESSION['token'] = true;
}//check for token
if (isset($_POST['token']) && isset($_SESSION['token']) && $_POST['token'] == $_SESSION['token'])
{//token is correct
$token_age = time() - $_SESSION['token_time'];
if ($token_age >= 5)
{//token correct but timeout
echo "Sorry Timeout!";
exit;
}
if(isset($_POST['secCode']) && isset($_SESSION['secCode']) && $_POST['secCode'] == $_SESSION['secCode'] )
{
// correct security code, now validate nameand other field
if(isset($_POST['name']))//name field is set
{
$n = $_POST['name'];
if (strlen($n) > 0 && strlen($n) < 31 && preg_match("/^[a-zA-Z'-]+$/", $n)) //valid and sql friendly name now in $name
{
$name=clean($_POST['name']);
echo $name;
}
else {
// $n is not valid
echo "Hoptic recommends you to fill your name properly.";
}
else {
//name not set
echo "Hoptic detected that you left the name field blank.";
}
}
else {
// security code is invalid
echo "Hoptic detected that you filled the wrong code";
exit; }
}
else
{
echo "Wrong data!";
exit;
}
?>
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
iknownothing wrote:
and you can't have 2 ELSE's to the 1 IF statement (Looks like you've missed a few closing curly braces etc)
which part of the code are you pointing to. specify the line number
Ya i missed one cury bracket closing i have corrected it, but to whatever i post it just pints wrong data on the test localhost server and blank page on actual server.
<?php
require_once('clean.inc.php');
session_start();
if (!isset($_SESSION['token']))
{
session_regenerate_id();
$_SESSION['token'] = true;
}//check for token
if (isset($_POST['token']) && isset($_SESSION['token']) && $_POST['token'] == $_SESSION['token'])
{//token is correct
$token_age = time() - $_SESSION['token_time'];
if ($token_age >= 5)
{//token correct but timeout
echo "Sorry Timeout!";
exit;
}
if(isset($_POST['secCode']) && isset($_SESSION['secCode']) && $_POST['secCode'] == $_SESSION['secCode'] )
{
// correct security code, now validate nameand other field
if(isset($_POST['name']))//name field is set
{
$n = $_POST['name'];
if (strlen($n) > 0 && strlen($n) < 31 && preg_match("/^[a-zA-Z'-]+$/", $n)) //valid and sql friendly name now in $name
{
$name=clean($_POST['name']);
echo $name;
}
else {
// $n is not valid
echo "Hoptic recommends you to fill your name properly.";
}
}
else {
//name not set
echo "Hoptic detected that you left the name field blank.";
}
}
else {
// security code is invalid
echo "Hoptic detected that you filled the wrong code";
exit; }
}
else
{//token is correct
echo "Wrong data!";
exit;
}
?>
<?php
require_once('../../includes/clean.inc.php');
session_start();
if (!isset($_SESSION['token']))
{
session_regenerate_id();
$_SESSION['token'] = true;
}//check for token
if (isset($_POST['token']) && isset($_SESSION['token']) && $_POST['token'] == $_SESSION['token'])
{//token is correct
$token_age = time() - $_SESSION['token_time'];
if ($token_age >= 5)
{//token correct but timeout
echo "Sorry Timeout!";
exit;
}
if(isset($_POST['secCode']) && isset($_SESSION['secCode']) && $_POST['secCode'] == $_SESSION['secCode'] )
{
// correct security code, now validate nameand other field
if(isset($_POST['name']))//name field is set
{
$n = $_POST['name'];
if (strlen($n) > 0 && strlen($n) < 31 && preg_match("/^[a-zA-Z'-]+$/", $n)) //valid and sql friendly name now in $name
{
$name = trim($_POST['name']);
$name = mysql_real_escape_string($_POST['name']);
echo $name;
}
else {
// $n is not valid
echo "Hoptic recommends you to fill your name properly.";
}
}
else {
//name not set
echo "Hoptic detected that you left the name field blank.";
}
}
else {
// security code is invalid
echo "Hoptic detected that you filled the wrong code";
exit; }
}
else
{
echo "Wrong data!";
exit;
}
?>
<?php
session_start();
if (!isset($_SESSION['token']))
{
session_regenerate_id();
$_SESSION['token'] = true;
}//check for token
if (isset($_POST['token']) && isset($_SESSION['token']) && $_POST['token'] == $_SESSION['token'])
{//token is correct
$token_age = time() - $_SESSION['token_time'];
if ($token_age >= 5)
{//token correct but timeout
echo "Sorry Timeout!";
exit;
}
if(isset($_POST['secCode']) && isset($_SESSION['secCode']) && $_POST['secCode'] == $_SESSION['secCode'] )
{
// correct security code, now validate nameand other field
if(isset($_POST['name']))//name field is set
{
$n = $_POST['name'];
if (strlen($n) > 0 && strlen($n) < 31 && preg_match("/^[a-zA-Z'-]+$/", $n)) //valid and sql friendly name now in $name
{
$name = trim($_POST['name']);
$name = mysql_real_escape_string($_POST['name']);
echo $name;
}
else {
// $n is not valid
echo "Hoptic recommends you to fill your name properly.";
}
}
else {
//name not set
echo "Hoptic detected that you left the name field blank.";
}
}
else {
// security code is invalid
echo "Hoptic detected that you filled the wrong code";
exit; }
}
else
{
echo "Wrong data!";
exit;
}
?>