pmg206 Posted April 26, 2006 Share Posted April 26, 2006 I'm sure this is a no-brainer, but be gentle -- I'm a PHP newbie coming over from the Dark Side (ASP and MSSQL). 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!_____________________________________________________________<? //initilize PHPif($_POST['submit']) //If submit is hit{ //then connect as user //change user and password to your mySQL name and password mysql_connect("server","username","password"); //select which database you want to edit mysql_select_db("ft4h"); //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)". "VALUES ('$call_recd','$recd_by','$caller_name','$caller_source','$caller_phone','$caller_altph','$notes','$disp_to','$disp_by','$disp_date')"); //confirm echo "Query Finished"; }else{// close php so we can put in our code?> </p> <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 </form></p><?} //close the else statement?> Quote Link to comment https://forums.phpfreaks.com/topic/8501-a-next-url-option-within-a-form/ Share on other sites More sharing options...
DepretioN Posted April 26, 2006 Share Posted April 26, 2006 Well, first of all... you really want to do alot more validation on the input being submitted to your form.But the code you are looking for ... put this after your query:[code]if ($result) header("Location: add_call-success.php");else echo "Query failed, did not submit values";[/code] Quote Link to comment https://forums.phpfreaks.com/topic/8501-a-next-url-option-within-a-form/#findComment-31109 Share on other sites More sharing options...
Caesar Posted April 26, 2006 Share Posted April 26, 2006 If you just need to figuire out the redirection part, just add:[code]header("location: thispage.php");[/code]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. ;-) ) Quote Link to comment https://forums.phpfreaks.com/topic/8501-a-next-url-option-within-a-form/#findComment-31110 Share on other sites More sharing options...
pmg206 Posted April 26, 2006 Author Share Posted April 26, 2006 Perfect -- it worked like a charm... thank you both!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.Thanks again! Quote Link to comment https://forums.phpfreaks.com/topic/8501-a-next-url-option-within-a-form/#findComment-31149 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.