This is by Newcustomer.php form whereby i click on the button next, it will proceed to the next form which is NewExpertise.php.
<form action = NewExpertise.php method="post">
<?php
include('CSS.php');
include('DB.php');
?>
<span class =wordtab>Name</span> <input name = newname id = 'newname' type='text'/> <br>
<span class =wordtab>IC</span><input name = newic id = 'newic' type='text'/><br>
<span class =wordtab>Number</span><input name = newnumber id = 'newnumber' type='text'/><br>
<span class =wordtab>Nationality</span><input name = newnationality id = 'newnationality' type='text'/><br>
<span class =wordtab>Status</span>
<select name = 'newstatus' id = newstatus>
<option value="Interested">Interested</option>
<option value='Not Interested'>Not Interested</option>
</select><br>
<span class =wordtab>Remarks</span><input name = newremarks id = 'newremarks' type='text'/><br>
<?php
?>
<br><br>
<input type="submit" id="Next" name="Next" value = "Next" >
<br><br>
<input type="button" onclick="location.href='index.php';" value="Back to CRM" />
</form>
This are my codes from newexpertise.php. It shows an sql to insert the new customer into my database. However i did a validation whereby if the textboxes are empty, i want it to go back to newcustomer.php and prompt them what fields are missing. If possible, how can i also validate fields whereby user and only type in numeric values in number textbox for example. Thank you so much.
if(isset($_POST['Next']))
{
if($_POST['newname']==""||$_POST['newic']==""||$_POST['newnumber']==""||$_POST['newnationality']==""||$_POST['newstatus']==""||$_POST['newremarks']=="")
{
$message = "Please fill in the all the relevant data";
echo "<script type='text/javascript'>alert('$message');</script>";
}
else
{
$addquery = "INSERT INTO Particulars (Particulars_ID, Name, Identification_Number, Number, Nationality, Status, Remarks)
VALUES(LAST_INSERT_ID(),'$_POST[newname]', '$_POST[newic]','$_POST[newnumber]','$_POST[newnationality]','$_POST[newstatus]','$_POST[newremarks]')";
if ($connect->query($addquery) === TRUE)
{
$last_id = $connect->insert_id;
}
else
{
echo "Error updating record: " . $connect->error;
}
}
}
?>
I would do the following: Post your newcustomer formula to newcustomer.php. if it validates use
header("Location: http://test.com/nextpage");
To redirect the user. If validation fails use this code to write the users values back into the form
<input id="test" name="test" value="<?php if(isset($_POST["test"])){echo $_POST["test"]}?>"/>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.