Link to home
Start Free TrialLog in
Avatar of m0tSiE
m0tSiE

asked on

PHP/mySQL Insert Form, Confirmation Message?

Hi,

I have put together the attached insert form to add records to my database, however I am looking to add a confirmation message once the user clicks submit.

The way I would like it to show is...

"Creation added, Click here to view this creation."

Can someone show me how to do this?

To view the creation the link would need to go to the page http://cawsearch.com/svr2008/view_caw.php?idx=$id

However the $id field is not filled in on the form as it is an auto increment field.

Thanks,
Paul.
<?
 
if(isset($_POST['submit'])){
$db = mysql_connect('', '', '') or die("Couldn't connect to the database.");
mysql_select_db('') or die("Couldn't select the database");
 
$console = $_POST['console'];
$name = $_POST['name'];
$attire = $_POST['attire'];
$type = $_POST['type'];
$creator = $_POST['creator'];
$formby = $_POST['formby'];
$image = $_POST['image'];
$thumbimage = $_POST['thumbimage'];
$image2 = $_POST['image2'];
$thumbimage2 = $_POST['thumbimage2'];
$image3 = $_POST['image3'];
$thumbimage3 = $_POST['thumbimage3'];
$video = $_POST['video'];
$formula = $_POST['formula'];
$date = $_POST['date'];
 
$sql = "insert into caws (console, name, attire, type, creator, formby, image, thumbimage, image2, thumbimage2, image3, thumbimage3,  video, formula, date) Values ('".$console."','".$name."','".$attire."','".$type."','".$creator."','".$formby."','".$image."','".$thumbimage."','".$image2."','".$thumbimage2."','".$image3."','".$thumbimage3."','".$video."','".$formula."','".$date."')";
$resultinsert = mysql_query($sql) or die(mysql_error());
}
?>
<form name="form1" method="post" action="<?php echo basename($_SERVER['PHP_SELF']); ?>">
<table width="761" border="2">
  <tr>
    <td>Console:
	<select size="1" name="console" id="console">
	<option value="ps2">Playstation 2</option>
	<option value="xbox360" selected>XBOX 360</option>
	</select>
    </td>
  </tr>
  <tr>
    <td>
      Name:
      <input type="text" name="name" id="name"></td>
  </tr>
  <tr>
    <td>Attire:
    <input type="text" name="attire" id="attire"></td>
  </tr>
  <tr>
    <td>Type:
	<select size="1" name="type" id="type">
	<option value="Wrestler" selected>Wrestler</option>
	<option value="Diva">Diva</option>
	<option value="Non-Wrestler">Non-Wrestler</option>
	<option value="Original">Original</option>
	</select>
    </td>
  </tr>
  <tr>
    <td>Creator:
    <input type="text" name="creator" id="creator"></td>
  </tr>
  <tr>
    <td>Formula By:
    <input type="text" name="formby" id="formby"></td>
  </tr>
  <tr>
    <td>Image:
    <input type="text" name="image" id="image"></td>
  </tr>
  <tr>
    <td>Thumb Image: <input type="text" name="thumbimage" id="thumbimage"></td>
  </tr>
  <tr>
    <td>Image 2:
    <input type="text" name="image2" id="image2"></td>
  </tr>
  <tr>
    <td>Thumb Image 2: <input type="text" name="thumbimage2" id="thumbimage2"></td>
  </tr>
  <tr>
    <td>Image 3:
    <input type="text" name="image3" id="image3"></td>
  </tr>
  <tr>
    <td>Thumb Image 3: <input type="text" name="thumbimage3" id="thumbimage3"></td>
  </tr>
  <tr>
    <td>Video: <input type="text" name="video" id="video"></td>
  </tr>
  <tr>
    <td>Formula: <textarea rows="2" name="formula" id="formula" cols="20"></textarea></td>
  </tr>
  <tr>
    <td>Date Added: <input type="text" name="date" value="<?php echo date("Y-n-j"); ?>" size=60></td>
  </tr>
  <tr>
    <td><input name="submit" type="submit">
	</form>
	</td>
  </tr>
</table>

Open in new window

Avatar of Ashish Patel
Ashish Patel
Flag of India image

So, you want to add confirmation on submit button or after the insert has been made?
Avatar of m0tSiE
m0tSiE

ASKER

After the insert as been made if possible.
ASKER CERTIFIED SOLUTION
Avatar of darron_chapman
darron_chapman
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of m0tSiE

ASKER

Awesome, cheers darron! :D