Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    PHP




Insert Form Info Into Database


i am trying to enter info from a form into a mysql database. when i submit the form, a new row is created, but the information isn't contained in it? any thoughts? PHP Code:




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Get And Insert Info Into Database
I have one table (form) that has multiple fields. Here are few fields we need to know: ID, NAME, CITY, STATE, PROFESSION, x, y, z (x, y, z means more than 50 fields that give me more information about each name).

The ID and NAME are unique and they don't change (each name has it's own ID). A NAME and its ID can be in any CITY, STATE or PROFESSION but this is fixed. That means if ID# 123 for Mr JOHN is Austin, TX, that will stay in Austin, TX for ever. I have more than 5000 NAME and it's ID, 9 professions, all US States and all Cities in my database.

Here is what I need to do:
I want to have a form on my site that my visitor finds his name first and then enters more information about him/her that will complete my database fields of x,y,z. What I'm thinking to do is to create a drop down list that the visitor first selects the profession. Based on the profession the second list shows the states that has that profession. Then by selecting the state, all the available cities will show up in the third list, and by selecting the city all the names related to that profession in that city, state will show up and he can select the name from the forth list. Then he enters other required information about him that will be send and saved in the database.

Here is what I have done and I know to do so far:
I have created the database with all the information in one table. I also know how to send data to database to be saved. But my problem at this point is how to create this list selection that narrows the search to find the right person.

Populating A Form Wth Database Info
I've coded a piece of code which populates a form with data read from the database:

$connection=mysql_connec ("localhost", "f2821842", "f2821842");
$result=mysql_select_db("QUERIES");
$query=mysql_query("Select * from Emp_Details where emp_num = '$employnum'");
while($row=mysql_fetch_array($query))
{$empname=$row['emp_name'];}

<form name="webregform" action="webadmin2.php" method="post">
<input name="requiredname" type="text" size="30" value="<?php echo "$empname"; ?>">
</form>

When I echo the $requiredname, I get spaces and no data, and I know that $empname is not a space-it does read a value in a database. 1. How can I get $requiredname to print a value?

Filling Form With Database Info
I have a table with 5 fields for a tour business activity list
: (1) id -table key (2) name (3)description (4)picture -text link not
binary(5) country. I would like to create a form that takes all the
activitys an puts it neatly down on site in checkboxes so user can
select activtys.this will be linked to form mail.i would like the
activitys to be seperated by the country they r in?

Validating Form Info Before Inserting It Into Database
I have been trying to create a PHP application where you can add customer contacts to a MySQL database.

Now, my problem began when I created a form where the user can add in a customer's name and info to the database. In an effort to alert the user that they may be adding a customer that is already setup in the database, knowing that some of the customers may have the same names, e.g. there is more than one Bobby Ray Brown, I decided to add a script that queries the "customers" table in the database and searches for all results that match the input from the user. Code:

Issue Insert ' Into Database From Form
I am unable to insert a ' through a form into my data base here where it is messing up i believe: PHP Code:

Insert Data From Form To MySQL Database
I have run createTable.php and everything is created. Now I want to run insertData.php. I want the user to enter stuff in the form & everything must be fill in before they click the submit button. It will call submitData() & all the information was enter will insert into the database. PHP Code:

Recall Database Info
Hi, I want to create a page where users can put in certain information like you normialy would in a form but when they click submit another page will load that will look like the original form the signed up with and everything they filed in that time will be there and they can make changes to that and then click submit and the changes are made to databse automaticialy.

How To Send Info To Database
im wondering how to submit info into a database.

i know the code goes something lie
$sql = "UPDATE <tablename> set $var = "var"

but i know that is wrong
and i want to put it in form so on submit it posts it in the database.

Info Deleted Itself From Database?
I got some info (news system) in a SQL database but after some days it deletes by itself it happened to me once but i thought i didnt remembered that i deleted it but today it happened again...it deleted by itself! lol

I have other tables in the same database so its a table problem...

How can i fix this? Did i miss something at the table configuration?

Retrieving Info From A Database
I would like the code below to fetch and display in an html table the Ad_Id, Date, and Type_Job fields from the 1st 10 rows of a table called employment. I'd like the results to be sorted first by date and then by the Ad_Id #. I have replaced my username and password with "user" and "password". Currently, the script returns the error:

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource

Also, the script is ignoring the css info that I have supplied. Code:

Ordering Info Returned From Database
I have a PHP page on my site which pulls back info from my MySQL database and displays it in a table under appropriate headings. Is there code that I could add to these headings so that

a) the same page could be redisplayed with the information sorted by the third column instead of the first
b) information in the columns could be displayed in reverse order (maybe Z to A or highest figure to lowest figure)

Session Variable Info To Database
I have a 2 page form. The first page page of the form POSTS to the 2nd page which, after being filled out, should send all the information (from pages 1 and 2) to the database. I have created a session variable and have placed it at the top of the 2nd page. For brevity´s sake I have placed only one of the variables in this example:

<?php
session_start();
$_SESSION["sessanimals"] = $_POST["animals"];
?>

After filling out the remaining variables on page 2, I want all the information (the info from page 1 brought over in the session variable and the info from page 2) sent to the database. I tried creating an INSERT RECORD on page 2 but only the variables on page 2 are subsequently sent upon submission. How do I get all the info into my database??

Here are a list of my questions:

1. Is there any way of creating one session variable for all my page 1 form variables (I have 20+ variables)?
2. is there a way to denote ALL the variables in = $_POST[]; or do they have to be listed separately?
3. How do I post all the data from page 1 and 2 into my database at once?

Update Database Info Using Forms
i have a page uses select and cases. i already have setup and working, auth/login to the page, create a new row in the table. i am now trying to have the user alter the information that the just put into the table.

this is the code where i have setup to modify the info, $id is passed over. this puts the correct information into the form field. when i hit submit, the information, $name, $content, $id are not passed over. echo-ing results blank. PHP Code:

Hiding Database Connection Info
In a php script, I have to connect to a remote mysql database. I'm a bit
worried that some user might be bale to retrieve the source of the page and
see the user name and password to connect to the db.

Is this resonable? What's the best way to avoid it?

Obtaining Info From Database Table
How do you obtain fields from a table and assign each field to a variable to be used as needed.
An example:

Say i had:

table name : user

Field 1 : User name
Field 2: Password

then i wanted:

$username = field 1
$password = field 2.

User Info Not Posting To Database
I am trying to figure out why my script isn't updating the information of the user names stored in the database. Can anyone give me the solution?
Below is the script: Code:

How To Obscure Database Info In PHP Pages
I'm moving from Cold Fusion to PHP and I have a question that none of
the books I have answers adequately:
In Cold Fusion, database connection parameters like the table, username
and password are configured on the server. Since they are at the
backend, nothing is exposed on the page except the queries themselves.
In PHP, from what I see, the database info is on the page. Is this not a
security risk? How can one be sure that this info is not on the page
sent to the user?

Entering/checking Info Into Mysql Database
I have set up a client database where one can view, add, edit and delete entries. I ran into a problem setting up the add page. On this page i have set up forms to add info into the DB, and it works fine, but i dont want duplicate clients. Is there a way to set it up so that when you submit the form with the info it checks for duplicates and if there is one returns "sorry this record exists?"

Retrieve An Image In Folder From Info Out Of Database
i am having problems displaying an image once i have uploaded
it. i upload it to a folder and store its name in a database. below is
the code to display the image. I have figured out the the code is not
grabbing the name from the database but i can not figure out why. can
anyone help?

//Retrieves data from MySQL
$data = mysql_query("SELECT IMAGE_NAME FROM item") or
die(mysql_error());

//Puts it into an array
while($info = mysql_fetch_array( $data ))
{
//Outputs the image and other data
Echo "<img src=http://www.abcxyz.com/pics/".$info['photo'] ."<br>";
}

Sends SMTP Mail From Database Info
I've got this script that I want to use to send SMTP mail from a form that allows the user to select recipients from a dropdown list that is created using database info and send a message.  Two of the selections in the dropdown list are groups.  My script works fine when the user selects only one recipient.  I run into trouble when the user selects one of the two groups.

The message ends up getting sent numerous times to the people in the group. I received the message 9 times.  I think the script is looping more times than it should.  Does this make sense so far?  Here's the script that receives the form data and connects to the DB to get the recipient email addresses and then sends the message: Code:

Retrieving Database Info Based On User
I'm still quite new to php and mysql but I have been unable to figure this out.  I'm attempting to display a specific row and column from a mysql database based on the user.

$result = mysql_query("SELECT fbleague FROM users WHERE username = $_SESSION[username]");
fbleague is the column
users is the table
username is the primary key column
$_SESSION[username] is the username variable

Then later I try to display it with

echo "You are in league $result ";

I know $_SESSION[username] is set correctly because I can display that with no problems. 

Php Form Info...
have a form, with a text input "fieldname".
method POST

$var = $_POST["fieldname"]

$var is then used to search in mysql

select * from table where jobtype like '$var%'
OR jobtype like '%$var%'
OR jobtype like '%$var'
OR jobtype like '$var' order by date asc;

basically i'm doing a search for any string that matches the searched
input, being at the beginning, middle or end of the jobtype column.

query works great, except when the string contains the 4-letter word
'info' such as information or informative
then the mysql query breaks down and give the usual:

Error performing query: You have an error in your SQL syntax. Check the
manual that corresponds to your MySQL server version for the right
syntax to use near 'ORDER BY date ASC' at line 1

Now after much debugging, i found out that the php _POST variable
treats anything with info as a numner of 0 value.
inf is treated as text, nformation is treated as text, but anything
with info gets a 0 value.

Searched php.net and couldn't find anything related to this feature,
looked under security to see if it was related to that, but nothing.

Php Form Info...
have a form, with a text input "fieldname".
method POST

$var = $_POST["fieldname"]

$var is then used to search in mysql

select * from table where jobtype like '$var%'
OR jobtype like '%$var%'
OR jobtype like '%$var'
OR jobtype like '$var' order by date asc;

basically i'm doing a search for any string that matches the searched
input, being at the beginning, middle or end of the jobtype column.

query works great, except when the string contains the 4-letter word
'info' such as information or informative
then the mysql query breaks down and give the usual:

Error performing query: You have an error in your SQL syntax. Check the
manual that corresponds to your MySQL server version for the right
syntax to use near 'ORDER BY date ASC' at line 1

Now after much debugging, i found out that the php _POST variable
treats anything with info as a numner of 0 value.
inf is treated as text, nformation is treated as text, but anything
with info gets a 0 value.

Searched php.net and couldn't find anything related to this feature,
looked under security to see if it was related to that, but nothing.

Can anyone look into it and elaborate?
create a form, then echo the value of the $_POST variable
and try words that contain info in them.

Uploading Info From A Text File Into A MySQL Database
what would the PHP and SQL code be to say basically: make a new row and put this in the field, what comes after each comma goes in a new field, and each new line should be a new row.

I have a huge text file that i don't have a way to upload directly into a MySQL database because my webhost isn't allowing it for some reason.

Getting Info Out Of Dynamic Form
I am using the following code to produce a dynamic form.

$result = mysql_query("SELECT id,weight,date FROM weekly_data WHERE
weight IS NULL AND subscr_id = '$toss' AND date <= now()");
if (!$result) {
die('Invalid query: ' . mysql_error());
}
print"<table width=ď`%' id='catchup' border=&#390;' cellspacing=&#390;'
cellpadding=&#390;'>";
print "<form name='form1' id='form1' method='post'
action='catchupprocess.php'>";
print"<tr>";
print"<td></td>";
print"<td>Weight</td>";
print"<td>Date</td>";
print"<td>Waist</td>";
print"<td>Measure</td>";
print"<td></td>";
print"</tr>";
while ($row = mysql_fetch_array ($result)){
//echo $result;
print"<tr>";
print"<td>";
print"<input name='".$row['id']."' size=&#394;' type='text'
value='".$row['id']."'/>";
print"</td><td>";
print"<input type='text' size=&#396;' name='weight".$row['id']."'
value=''/>";
print"</td><td>";
print"<input type='text' size=&#3910;' value='".$row['date']."'/>";
print"</td><td>";
print"<input type='text' size=&#393;' name='waist".$row['id']."'
value=''/>";
print"</td><td>";
print"<input type='text' size=&#396;' value='$measure'/>";
print"</td><td>";
print"<input type='hidden' size=&#3910;' value=''/>";
print"</td>";
print"</tr>";
}
print"<tr>";
print"<td>&nbsp;</td>";
print"<td><input name='Reset' type='reset' value='Reset'></td>";
print"<td>&nbsp;</td>";
print"<td><input name='submitcatchup' type='submit'
value='Submit'></td>";
print"<td>&nbsp;</td>";
print"</tr>";
print"</form>";
print"</table>";
?>

Persistent Form Info
I have some forms that have different parts, and it decides which parts to display through the url ie form.php?showpart=1, showpart=2, etc. If I want to show another part and change the url all the form info goes away.  I'm a self taught PHP guy, I'm decent but not amazing.  My current solution is to use AJAX to write/modify a cookie everytime the user writes something and bring that in when they change the page. Is there an easier way?

Printing Out Info From A Form
I have this php function that reads a text file for input to create a form. I am trying to get the form to print out the data on a separate page, but all I get is a blank page. Am I calling the page correctly, or is this even possible to do? Code:

Upload & Query MySQL Info Database With Image Files
I want a database I can enter information and upload a photo from a web form. Then I want to query that database for the text info with its related photo and display it (formatted) in a browser (html).

Summary:

1. upload photo's and text information to database with my add article form.
2. Query the database and page the results with the text and related photo.

It comes in three parts:

1. add_article.php [Text / Photo Upload Form]
2. insert_article.php [Inserts into database]
3. articles.php [View Output]

Here is what I have this far:

Database Insert
I want to insert data into two tables of a database. Basically i want to insert into table1 then use the automatically generated auto increment id number as a variable in the second part of the insert. any ideas how to go about doing this?

Insert Into Database
I am currently working on committing this to the database.  however my problem is that not all of these fields may be populated.  For example q3c may be left blank therefore only two records need committing to the db instead of three. Code:

Database Insert
ive wrote a very simple News Script, but the only way i can add news to it is iva PHPmyadmin. I have no idea how to write the code to insert the information into a database.

Insert To Database
i want to do a simple insert into my database. The code works but nothing is inserted. I have removed the usernames and passwords for obvious reasons. Code:

Referer And Keyword Info Sent Via Form?
I've learned that HTTP_REFERRER, at least in my tests, returns the page visted on the current domain before the form page, not the domain visited before the current domain, so that hasn't been useful. I don't know how I would get keywords in this case. I've searched around for scripts or tutorials and have been surprised to find nothing helpful

The site in question has a separate stats package, but it doesn't track converting keywords and that's really what I'm after. There isn't high volume traffic, so getting them individually via a form (rather than input into a database) isn't a problem.

My question is really whether what I'm trying to do is possible with a few lines of code, or have I underestimated the complexity of the task?

Some Users Can't Enter Info Through My Form To My DB
I set up a comment page on my site and most users can enter comments.  the page refreshes and shows the comments below.  however, some users can't enter comments.  what should I be looking for to resolve this?

Insert Into Mysql Database
It sounds very simple, but for some reason I just can't figure it out, and it will save a lots of time to me, if someone can direct me into the right direction. I was trying to input data into mysql table through post method, but it was not working. I made it simple and just tried to enter anything from a php file, but it does not work, so there is something that i am doing wrong with the insertion query.

$link = mysql_connect($hostName, $userName, $password);
echo("connected");

mysql_select_db($databaseName, $link);
echo("database selected");
echo ($databaseName);

mysql_query("INSERT INTO image VALES('','','','','','','','','', 'hello', '', '', '','','','','')", $link);

echo ("done");

I am trying to enter into one of those fields, but it does not populate the table in mysql database.

Can't Write In The Database Using INSERT INTO
This is my script:

$table_to_use = "irr_accounts";
include ($_SERVER['DOCUMENT_ROOT'].'/snippets/cnx.php');

$query = "INSERT INTO $table_to_use (account_number, handling_branch, acct_type, school, address, street, city, contact_person, contact_number, first_name, last_name, date_applied, date_approved, end_date, status) VALUES

('$account_number', '$handling_branch', '$account_type', '$school', '$address', '$street', '$city', '$contact_person', '$contact_number', '$first_name', '$last_name', &#3900;-00-00', &#3900;-00-00', &#3900;-00-00', '$status')";

mysql_query("COMMIT");

Trying To Insert Data In A Database
I am trying to insert data in a database
Code:

Insert A Image To The Database
I tried to insert a image to the database but whenever I do I get a error message called 'invalid hex code' any idea guys?

Database Insert Security
I have a general question about security when inserting into a database. I just now realized that magic quotes in turned on. I discovered it while testing the formatting of my mail function. One of the words I typed had a single quote in it that got escaped. My next step is to insert the data into a MySQL database. I don't have the option to turn off magic quotes because I don't have access to the php.ini. Does this mean that every time I use data sent by a POST that I need to stripslashes?

Are the magic quotes enough security when inserting into a database? Should I be doing more to make sure that I am not the victim of a SQL injection? Should I also use htmlentities? Are the other measures I should be taking? At what point does this become overkill?

PHP Displaying Info Input On HTML Form
I'm in an exercise where I've created an order form in HTML. The form displays properly and allows me to input certain test order info just fine. The relevant lines in the HTML form are: Code:

Getting Form Info Into A Mysql Select Statement
I'd like to get user input from an html form into a mysql select
statement. Here's where I'm stumped:

$result = mysql_query("SELECT * FROM dept WHERE notes LIKE
'%search-string%'",$db);

I need to get the user's input into the '%search-string%' section, but I
do not understand how to do this. I can hard-code a specific search
string and it will work, but I want the users to be able to dynamically
define the search-string. So, I created a basic html form and used the
post method to grab their input, but now I can't insert that input into
the mysql select statement. Any ideas? I think it should be easy, I just
don't know how to do it. I've tried this:

$result = mysql_query("SELECT * FROM dept WHERE notes LIKE
'%$_POST["search"]%'",$db);

But it doesn't work. Below is the form in html and the php file:

<html>
<title>Search Test</title>
<head>
</head>
<body>
<form action="search-db.php" method="POST">
<p>Enter Your Search: <input type=text name=search></p>
<input type="submit">
</form>
</body>
</html>
-----------------------------------------------------------
<html>
<body>
<?php
$db = mysql_connect("localhost", "Anonymous");
mysql_select_db("computers",$db);
$result = mysql_query("SELECT * FROM dept WHERE notes LIKE
'%surplus%'",$db);
echo "<table border=1>
";
while ($myrow = mysql_fetch_array($result)) {
printf("<tr><td><b>%s</b></td></tr>
", $myrow[notes]);
}
echo "</table>
";
?>
</body>
</html>

Upload And Email Form Info At The Same Time
I need to upload something and also have an email sent at the same time after filling out a form. So they will fill out a form, decide what they want to upload and then hit the submit button and it will upload the file to my directory, where I can get to it, and then it will also email me the information I had them fill out in the form at the same time. Is that possible? What code would I use?

Taking Info From A Form, Saving It In A DB And Writing It To A .css
What I need to do is take "site info" from a form, save it to a database table called siteinfo, and then write style information based on the variables. Code:

How Do I INSERT A Value That Contains A Variable Into A MySQL Database?
I'm trying to insert values into my database that contain a variable
that gets incremented by one for each item in a shopping cart.
item_name becomes item_name1, item_name2, item_name3, and so on for
the total number of items in the cart.

This code works great when i only have one shopping cart item to deal
with.....

To Insert Array Value In Database---important
ihad an array in php and iwant to insert its value in database
the coding is:

<?php
$nv_pairs = explode('&',$query_string);
$array[50];
list ($name, $value) = explode ('=',$nv_pairs);
$i = 0;
foreach($nv_pairs as $array[$i]) {
$array[$i]=
preg_replace('/\%0d%0a+/',"<br> &nbsp;&nbsp;&nbsp;&nbsp;
; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
; ",$array[$i]);
$array[$i]= urldecode ($array[$i]);
$array[$i]= preg_replace('/d*=/', " ",$array[$i]);
$array[$i]= urldecode ($array[$i]);
$i++;
}
ksort($array);
while(list($key,$value)=each($array)) {
if (preg_match("/d+/",$value)) {
echo "<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;<b>$value</b>";
}
else {
echo " <b>$value</b>";
}
}
?>

Insert New Record To Database Without Duplicating
Is there a simple way when inserting a new record to a database to only execute if it is not duplicating an existing record? The way I would currently do this is to query the database first with the new values and see if I get a match, but is there simpler way?

Unable To Insert All My Values Into The Database
I have an error in my code because its not inserting my $_session['identity']  into the database. I know the session has a value because I am able to display it on the page. it just wont insert it into the database. Code:

Can't Insert Record Into Access Database
I'm trying to create a registration/login script using Access 2003. I'm using ADOdb to connect through ODBC.

The problem is that I get the little custom error Could Not Connect to Server when I try to insert a record, yet when I use the form with a username I inserted through Access it reads it just fine and returns if the username has been used. Also if I removed line line 23 or die('<b>Could Not Connect to Server</b>'); and it'll complete the script, but it won't insert the record. Code:

How To Insert Arrays Into Mysql Database
This is my order.php file. Now I try to make a new php-file for processing the ordered items on this page, into another table "ordered_products" in the database. I want to INPUT following values into the table "ordered_products":
'order_num', 'order_item' and 'order_ant'

I know how to insert rows in a table using the INSERT query, but I don't know how to do it while looping the arrays. I have to fetch the arrays from this page, and insert them row by row in the "ordered_products" table. Code:


Copyright © 2005-08 www.BigResource.com, All rights reserved