A 'next URL' option within a form?
Posted 26 April 2006 - 09:20 PM
I have a form that, upon submission, ideally should allow me to kick them to a "success!" sort of page (and display a confirmation of their input, of course). Probably because I don't know how to phrase it, I can't for the life of me find the command/syntax for doing this.
The code I'm using is below. The page that houses this code is add_call.php, and the goal is, upon submit, forwarding the user to add_call-success.php. A quick point in the right direction, or even a good place to read up on forms, would be most appreciated.
Thanks in advance!
if($_POST['submit']) //If submit is hit
//then connect as user
//change user and password to your mySQL name and password
//select which database you want to edit
//convert all the posts to variables:
$call_recd = $_POST['call_recd'];
$recd_by = $_POST['recd_by'];
$caller_name = $_POST['caller_name'];
$caller_source = $_POST['caller_source'];
$caller_phone = $_POST['caller_phone'];
$caller_altph = $_POST['caller_altph'];
$notes = $_POST['notes'];
$disp_to = $_POST['disp_to'];
$disp_by = $_POST['disp_by'];
$disp_date = $_POST['disp_date'];
//Insert the values into the correct database with the right fields
$result=MYSQL_QUERY("INSERT INTO calls (call_recd,recd_by,caller_name,caller_source,caller_phone,caller_altph,notes,disp_to,disp_by,disp_date)".
echo "Query Finished";
// close php so we can put in our code
<form name="add" method="post" action="add_call.php"> //
... plain old HTML <table> with fields and such (add_call.php is the page here; we want to send 'em to add_call-success.php
} //close the else statement
Posted 26 April 2006 - 09:27 PM
But the code you are looking for ... put this after your query:
if ($result) header("Location: add_call-success.php"); else echo "Query failed, did not submit values";
Posted 26 April 2006 - 09:28 PM
In your if statement, after you've done everything else you need to do.
(Note: I am at work and not really looking at things in much detail or focus...so I hope I did not misunderstand. Plus, I am in A.D.D mode. ;-) )
Posted 26 April 2006 - 10:29 PM
Good feedback on the validation, too. This is a HUGE learning curve for me between letting Dreamweaver write some of the ASP and just validating it versus trying to do more hand-coding with php.net, this site and a Dummies book as my guides (the latter being a little too focused on their task list to help with the specific stuff). This particular form is just for me to track something personally, so I didn't get hung up on the validation -- yet -- but for the future project meant for the public, validation is a big 10-4.
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users