Jump to content

Recommended Posts

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

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

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.