simon551 Posted June 19, 2007 Share Posted June 19, 2007 Hi, I'm trying to separate my php action from the page that the form is on, but it's not working; trying to figure out what I'm doing wrong here with a form action. This is the form tag: <form method="post" name="form1" action="../sources-php/timesheet_current_submit.php"> When I hit the submit button, the form window is actually going to the 'timesheet_current_submit.php' page, which is blank because it just has some php code to insert a record. Link to comment https://forums.phpfreaks.com/topic/56265-form-action/ Share on other sites More sharing options...
wildteen88 Posted June 19, 2007 Share Posted June 19, 2007 huh! the action attribute submits the data to the specified file. So when you submit the form the browser will go to and submit the form data to the url specified in the action attribute. Link to comment https://forums.phpfreaks.com/topic/56265-form-action/#findComment-277921 Share on other sites More sharing options...
akitchin Posted June 19, 2007 Share Posted June 19, 2007 that's exactly what the form action is supposed to do - it's supposed to send the form request data to the script specified in the action attribute. if you want it to come back to the form page, you'll need to redirect from timesheet_current_submit.php to the form page once it's done what it's supposed to do. i might be missing something in your question. EDIT: beaten to the punch, but i'm leaving this here because i don't want to have wasted the finger movement. Link to comment https://forums.phpfreaks.com/topic/56265-form-action/#findComment-277923 Share on other sites More sharing options...
simon551 Posted June 19, 2007 Author Share Posted June 19, 2007 Ah. I see. That makes sense. So the fact that I'm just directed to the blank php page is that in the following code,from 'timesheet_current_submit.php' it's not making it to the re-direct part. I learned something anyway. Now I just need to figure out why it's not working. Thanks. And thanks in advance for any more guidance. if ((isset($_POST["form1"]))) { $insertSQL = sprintf("INSERT INTO timesheet_entries (id_timesheets_main, id_timesheet_code, id_project, time_beg, time_end, description, hours, minutes) VALUES (%s, %s, %s, %s, %s, %s, %s, %s)", GetSQLValueString($_POST['id_timesheets_main'], "int"), GetSQLValueString($_POST['id_timesheet_code'], "int"), GetSQLValueString($_POST['id_project'], "int"), GetSQLValueString($_POST['time_beg'], "date"), GetSQLValueString($_POST['time_end'], "date"), GetSQLValueString($_POST['description'], "text"), GetSQLValueString($_POST['hours'], "double"), GetSQLValueString($_POST['minutes'], "double")); mysql_select_db($database_conn_org, $conn_org); $Result1 = mysql_query($insertSQL, $conn_org) or die(mysql_error()); $insertGoTo = "../Timesheets/timesheet_current.php"; header(sprintf("Location: %s", $insertGoTo)); } Link to comment https://forums.phpfreaks.com/topic/56265-form-action/#findComment-277931 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.