Forum Moderators: coopster
I've been at this for a week now and im still struggling, any help would be so so good. I think the problem lies with the way im testing if the form has been submitted although it works on a single page.
Below is the code for my home page, i am loading .inc files into the main content div box. I've taken some code out so dont worry if theres a missing <head> or something.
<?php
require_once("postback.php"); // for postback function
require_once("initFuns.php") ; // initialise page function
$titles = array(); // create empty array
$files = array();
$menu = "";
initPage("manifest.inc","nav");
if ($indx>0)
$index = getParameter('indx');
else
$index = 0;
$inc = $files[$index];
if (file_exists($inc))
$contents = file_get_contents($inc);
else
$contents = file_get_contents("manifest.inc");
$title = $titles[$index];
?><body>
<div id="main">
<h1><?=$title?></h1>
<?
if($index==0)
{
include("home.inc");
}
else{include("signup.inc");}?>
</body>
</html>
Here is the code im loading into the above page's main div box. Its called signup.inc
<?
require_once "connection.php";
require_once "postback.php";
$missingData = false;
if (isset($_POST['submitform']))
{ // check that fields are not empty$firstN = getParameter("firstN1");
if ( strlen($firstN)> 0 && strlen($secondN)> 0 && strlen($userN)> 0 && strlen($password)> 0
&& strlen($address1)> 0 && strlen($address2)> 0 && strlen($town)> 0 && strlen($postcode)> 0
&& strlen($phone)> 0)
{
$qry = "insert into Account values(\"$firstN\",\"$secondN\",\"$userN\",\"$password\",
\"$address1\",\"$address2\",\"$town\",\"$postcode\",\"$phone\")" ;
$result= mysql_query($qry);
if ($result) {
$id = mysql_insert_id();
}
else {
die('Invalid query: ' . mysql_error());
$id = -1 * mysql_error();
}
header("location:insertOk.php?id=$id");
}
else $missingData = true;
}?>
<head>
<title>Jupiter</title>
<link rel="stylesheet" type="text/css" href="style.css" />
</head>
<p>Please fill in All fields</p>
<? if ($missingData):?>
<p> Missing Data </p>
<? endif;?>
<form action="<?= $_SERVER['PHP_SELF'];?>" method="post">
<fieldset>
<legend align="left">personal details</legend>
<label for="firstN1">First Name:</label>
<input type="text" name="firstN1" value="" size="20" maxlength="20"/>
<br>
</fieldset>
<input type="submit" name="submitform" value="Register"/>
</form>
Thank you so much for any help!
Lewis.
if ($indx>0)
$index = getParameter('indx');
else
$index = 0;
<input name="indx" type="hidden" value="<?=$index;?>">
baze