Hi guys,
I'm kind of new to PHP/MySQL and I have had a google to try and find an answer to my question but so far I have had no luck so I thought I would ask someone.
I think my problem is fairly easy to solve its just I cant figure out how to do it! :S
Basically I want to submit form data to a new record in a my SQL database. I had it working that on submit it would run a validation script (JavaScript) then if that returned true it would save data to database and replace the form with a confirmation message. That all worked fine.
The problem is I actually need to send user to a different page, rather than just echo a confirmation message, as I am parsing some data (unique project code) using a query string to this other page. I don't know how to save data before redirecting! Currently the form validates and the page changes but the data isn't being saved!
PHP Script:
<?php
if (!isset($_POST['submit'])) {
?>
<!-- start content -->
<div id="content">
<div class="post">
<h1 class="title">/ Create New Project</h1>
<form id="createForm" action="" onsubmit="return validateForm()" method="post">
<input blah blah />
</form>
</div>
</div>
<!-- end content -->
<?php
} else {
$title = $_POST['project_title'];
$country = $_POST['country'];
$city = $_POST['city'];
$project = $_POST['description_txt'];
$artist = $_POST['artist_name'];
$artistage = $_POST['artist_age'];
$artisturl = $_POST['artist_url'];
$user = $_POST['user_txt'];
$query = "INSERT INTO news VALUES ('','$code','$title','$country','$city','$project','$artist','$artistage','$artisturl','$user')";
mysql_query($query);
}
mysql_close();
?>
Validation:
}else{
//A-OK
document.getElementById('createForm').action = "viewNew.php?projectCode="+201;
return true;
}
Any suggestions would be greatly appreciated. Thanks
Chewwie