forms and $_Post (I know you've never heard this one b4)
Posted: Tue Jan 05, 2010 6:56 pm
Hello Board,
I’m new here and sort of new to php. I’m just getting my head around it now and have, what I think is, such a common problem.
Here's the scoop:
Latest PHP
Latest MySQL DB
trblticket.php is where my form resides.
db_config.php is where my connection string resides.
trbltckinsert.php is where my insert statement and handlers reside.
Successfully created a form and script to process/handle it, insert it...... when passing only text.
Then I adjusted my new table to work with the rest of my database.
PROBLEM is I neglected to think about the need to insert allot of my form data as datetime, int(10), tinyint, and varchar and I can't for the life of me get them all handled.
I assume thats what I need..... a handler. I got a checkbox to work by using
$RushJob_opts = $_POST['RushJob'][0];
I don't even want to mention everything I;ve tried.
Could someone kindly tell me how to "handle" passing
1.) m-d-Y datetime to format Y-m-d H
s
2.) insert todays date
3.) insert todays date + 2 days
4.) a number to int(10)
5.) 0 or 1 to tinyint
6.) number to smallint
Here is a small sample of my form. And a small sample of my code
From FORM: <input type=hidden name=parent_id id=parent_id value="0">
And here is some of the trbltckinsert.php
THANKS IN ADVANCE!
I’m new here and sort of new to php. I’m just getting my head around it now and have, what I think is, such a common problem.
Here's the scoop:
Latest PHP
Latest MySQL DB
trblticket.php is where my form resides.
db_config.php is where my connection string resides.
trbltckinsert.php is where my insert statement and handlers reside.
Successfully created a form and script to process/handle it, insert it...... when passing only text.
Then I adjusted my new table to work with the rest of my database.
PROBLEM is I neglected to think about the need to insert allot of my form data as datetime, int(10), tinyint, and varchar and I can't for the life of me get them all handled.
I assume thats what I need..... a handler. I got a checkbox to work by using
$RushJob_opts = $_POST['RushJob'][0];
I don't even want to mention everything I;ve tried.
Could someone kindly tell me how to "handle" passing
1.) m-d-Y datetime to format Y-m-d H
2.) insert todays date
3.) insert todays date + 2 days
4.) a number to int(10)
5.) 0 or 1 to tinyint
6.) number to smallint
Here is a small sample of my form. And a small sample of my code
From FORM:
Code: Select all
<li class="mainForm" id="fieldBox_8">
<label class="formFieldQuestion">start_date</label><input type=text name=start_date id=start_date value="">
<button type=reset class=calendarStyle id=fieldDateTrigger_8></button>
<SCRIPT type='text/javascript'> Calendar.setup({
inputField : "start_date",
ifFormat : "%m/%d/%Y",
showsTime : false,
button : "fieldDateTrigger_8",
singleClick : true,
step : 1
});</SCRIPT></li>
Code: Select all
From FORM: Need this to be int(10)And here is some of the trbltckinsert.php
Code: Select all
include("db_config.php");
$link = mysql_connect($db_host,$db_user,$db_pass);
if(!$link) die ('Could not create ticket. Could not connect to DB: '.mysql_error());
mysql_select_db($db_name,$link);
$query = "INSERT into `".$db_table."` (Name,Email,Phone,parent_id,title,text,due_date,start_date,assigned_to_company_id,assigned_to_user_id,assigned_on,assigned_by_id,time_estimate,completed_on,completed_by_id,created_on,created_by_id,updated_on,updated_by_id,trashed_on,trashed_by_id,archived_on,archived_by_id,started_on,started_by_id,priority,state,order,milestone_id,is_private,is_template,from_template_id,repeat_end,repeat_forever,repeat_num,repeat_d,repeat_m,repeat_y,repeat_by,object_subtype, RushJob) VALUES ('" . $_POST['Name'] . "','" . $_POST['Email'] . "','" . $_POST['Phone'] . "','" . $_POST['parent_id'] . "','" . $_POST['title'] . "','" . $_POST['text'] . "','" . $_POST['due_date'] . "','" . $_POST['start_date'] . "','" . $_POST['assigned_to_company_id'] . "','" . $_POST['assigned_to_user_id'] . "','" . $_POST['assigned_on'] . "','" . $_POST['assigned_by_id'] . "','" . $_POST['time_estimate'] . "','" . $_POST['completed_on'] . "','" . $_POST['completed_by_id'] . "','" . $_POST['created_on'] . "','" . $_POST['created_by_id'] . "','" . $_POST['updated_on'] . "','" . $_POST['updated_by_id'] . "','" . $_POST['trashed_on'] . "','" . $_POST['trashed_by_id'] . "','" . $_POST['archived_on'] . "','" . $_POST['archived_by_id'] . "','" . $_POST['started_on'] . "','" . $_POST['started_by_id'] . "','" . $_POST['priority'] . "','" . $_POST['state'] . "','" . $_POST['order'] . "','" . $_POST['milestone_id'] . "','" . $_POST['is_private'] . "','" . $_POST['is_template'] . "','" . $_POST['from_template_id'] . "','" . $_POST['repeat_end'] . "','" . $_POST['repeat_forever'] . "','" . $_POST['repeat_num'] . "','" . $_POST['repeat_d'] . "','" . $_POST['repeat_m'] . "','" . $_POST['repeat_y'] . "','" . $_POST['repeat_by'] . "','" . $_POST['object_subtype'] . "','" . $_POST[‘RushJob’] . "')";
VALUES ('" . $_POST['Name'] . ";
mysql_close($link);
THANKS IN ADVANCE!