Form submit

This is a discussion on "Form submit" within the PHP Forum section. This forum, and the thread "Form submit are both part of the Program Your Website category.



Go Back   Webforumz.com > Main Forums > Program Your Website > PHP Forum

Notices


Reply
 
LinkBack Thread Tools
  #1 (permalink)  
Old Nov 24th, 2007, 11:48
Reputable Member
Join Date: Oct 2007
Location: Liverpool UK
Age: 29
Posts: 216
Thanks: 0
Thanked 0 Times in 0 Posts
Form submit

Below is a form with PHP code, can anyone tell me why the data from the form once filled is not being submitted into my database?

Created a form like this plenty of times, but when i make it larger it appears not to work! Its real basic PHP code, and i have probebly missed somthink being dozy!

Thanks!

PHP: Select all

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<form enctype="multipart/form-data" action="add.php" method="POST"> 
Name: <input type="text" name="first_name"><br> 
Surname: <input type="text" name = "last_name"><br> 
Address: <input type="text" name = "address"><br>
City: <input type="text" name = "city"><br>
Area: <input type="text" name = "area"><br>
Email: <input type="text" name = "email"><br>
Phone: <input type="text" name = "phone"><br>
User_name: <input type="text" name = "user_name"><br>
Password: <input type="text" name = "password"><br>
Work_location: <input type="text" name = "work_location"><br>
Agency_name: <input type="text" name = "agency_name"><br>
Agency_number: <input type="text" name = "agency_number"><br>
Skills: <input type="text" name = "skills"><br>
about: <input type="text" name = "about_me"><br>
Myspace_address: <input type="text" name = "myspace_address"><br>
Hotmail_yahoo_address: <input type="text" name = "hotmail_yahoo_address"><br>
Gender: <input type="text" name = "gender"><br>
Age: <input type="text" name = "age"><br>
Height_one: <input type="text" name = "height_one"><br>
Height_two: <input type="text" name = "height_two"><br>
Build: <input type="text" name = "build"><br>
Eye_colour: <input type="text" name = "eye_colour"><br>
Hair_colour: <input type="text" name = "hair_colour"><br>
Desired_work: <input type="text" name = "desired_work"><br>
 
 
 
 
Photo: <input type="file" name="image_one"><br>
Photo: <input type="file" name="image_two"><br>
Photo: <input type="file" name="image_three"><br>
Photo: <input type="file" name="image_four"><br> 
<input type="submit" value="Add">
</form>
</body>
<?php 
//This is the directory where images will be saved 
$target "images/"
$target $target basename$_FILES['photo']['image_one']);
$target $target basename$_FILES['photo']['image_two']);
$target $target basename$_FILES['photo']['image_three']);
$target $target basename$_FILES['photo']['image_four']);
 
//This gets all the other information from the form 
$Name=$_POST['first_name']; 
$Surname=$_POST['last_name']; 
$Address=$_POST['address'];
$City=$_POST['city'];
$Area=$_POST['area'];
$Email=$_POST['email'];
$Phone=$_POST['phone'];
$User_name=$_POST['user_name'];
$Password=$_POST['password'];
$Work_location=$_POST['work_location'];
$Agency_name=$_POST['agency_name'];
$Agency_number=$_POST['agency_number'];
$Skills=$_POST['skills'];
$About=$_POST['about_me'];
$Myspace_address=$_POST['myspace_address'];
$Hotmail_yahoo_address=$_POST['hotmail_yahoo_address'];
$Gender=$_POST['gender'];
$Age=$_POST['age'];
$Height_one=$_POST['height_one'];
$Height_two=$_POST['height_two'];
$Build=$_POST['build'];
$Eye_colour=$_POST['eye_colour'];
$Hair_colour=$_POST['hair_colour'];
$Desired_work=$_POST['desired_work'];
 
 
 
$pic=($_FILES['photo']['image_one']);
$pic=($_FILES['photo']['image_two']);
$pic=($_FILES['photo']['image_three']);
$pic=($_FILES['photo']['image_four']); 
 
mysql_connect("localhost""root""longstand1") or die(mysql_error()) ; 
mysql_select_db("dbsignup") or die(mysql_error()) ; 

mysql_query("INSERT INTO `customer` VALUES ('$first_name', '$last_name', '$address', '$city', '$area', '$email', '$phone', '$user_name', '$password', '$work_location', '$agency_name', '$agency_number', '$skills', '$about_me', '$myspace_address', '$hotmail_yahoo_address', '$gender', '$age', '$height_one', '$height_two', '$build', '$eye_colour', '$hair_colour','$desired_work')") ; 
 
if(
move_uploaded_file($_FILES['photo']['tmp_name'], $target)) 

 
echo 
"The file "basename$_FILES['uploadedfile']['image_one']). "has been uploaded, and your information has been added to the directory"

else { 

echo 
"Sorry Andy There Was A Problem Uploading The File."

?> 
</html>
Reply With Quote

  #2 (permalink)  
Old Nov 24th, 2007, 11:54
Marc's Avatar
Moderator

SuperMember
Join Date: Apr 2007
Location: Scotland, UK
Age: 15
Posts: 1,650
Thanks: 0
Thanked 8 Times in 8 Posts
Send a message via MSN to Marc Send a message via Skype™ to Marc
Re: Form submit

Do you not need to list your column names in your Insert statement?

This is one of mine...

Code: Select all
   $query = mysql_query("INSERT INTO author_details (id, auth_name, website_url, auth_email, current_status, team_contact, final_response, cont_again, comments) VALUES ( '', '{$authname}', '{$authurl}', '{$authemail}', '{$currentstat}', '{$teamname}', '{$finalresponse}', '{$contactagain}', '{$comments}')") or die(mysql_error());
You may also want to add 'or die(mysql_error())' to see if it is an error that is causing it not to insert.

Hope that helps.
Reply With Quote
  #3 (permalink)  
Old Nov 24th, 2007, 14:11
Reputable Member
Join Date: Oct 2007
Location: Liverpool UK
Age: 29
Posts: 216
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Form submit

Hello Marc, how are you today?

I have just tried what you said & altered the code to suit, its still not working!

I am using Mysql administrator to check if the data has gone into teh database, and it is creating new lines but leaving the coloumns blank, any ideas

Cheers,
Reply With Quote
  #4 (permalink)  
Old Nov 24th, 2007, 15:27
c010depunkk's Avatar
SuperMember

SuperMember
Join Date: Apr 2007
Location: Willich, Germany
Age: 20
Posts: 593
Blog Entries: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to c010depunkk
Re: Form submit

These variable names:
PHP: Select all

$Name=$_POST['first_name']; 
$Surname=$_POST['last_name']; 
$Address=$_POST['address'];
$City=$_POST['city'];
$Area=$_POST['area'];
$Email=$_POST['email'];
$Phone=$_POST['phone'];
$User_name=$_POST['user_name'];
$Password=$_POST['password'];
$Work_location=$_POST['work_location'];
$Agency_name=$_POST['agency_name'];
$Agency_number=$_POST['agency_number'];
$Skills=$_POST['skills'];
$About=$_POST['about_me'];
$Myspace_address=$_POST['myspace_address'];
$Hotmail_yahoo_address=$_POST['hotmail_yahoo_address'];
$Gender=$_POST['gender'];
$Age=$_POST['age'];
$Height_one=$_POST['height_one'];
$Height_two=$_POST['height_two'];
$Build=$_POST['build'];
$Eye_colour=$_POST['eye_colour'];
$Hair_colour=$_POST['hair_colour'];
$Desired_work=$_POST['desired_work']; 
and these here:
PHP: Select all

mysql_query("INSERT INTO `customer` VALUES ('$first_name', '$last_name', '$address', '$city', '$area', '$email', '$phone', '$user_name', '$password', '$work_location', '$agency_name', '$agency_number', '$skills', '$about_me', '$myspace_address', '$hotmail_yahoo_address', '$gender', '$age', '$height_one', '$height_two', '$build', '$eye_colour', '$hair_colour','$desired_work')") ; 

are different. Variable names are case-sensitive. And some of the variable are just completely different.... The query is working perfectly, it's inserting empty values into the database because the variables are all empty.....
Reply With Quote
  #5 (permalink)  
Old Nov 24th, 2007, 15:34
Reputable Member
Join Date: Oct 2007
Location: Liverpool UK
Age: 29
Posts: 216
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Form submit

Damn i have been told this before by Alex Geek and i have made the same mistake twice, am getting better but still making dosy "A_s mistakes all the time

Ha ha its the only way you learn i suppose,

Thanks for your help mate!

By the way i added you to me MSN, is the end of your address supposed to say .de or .com ?

Take Care!
Reply With Quote
  #6 (permalink)  
Old Nov 24th, 2007, 15:53
Reputable Member
Join Date: Oct 2007
Location: Liverpool UK
Age: 29
Posts: 216
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Form submit

Ok c010depunkk was right by fixing the varables all the data from the form has been posted into the database fine the only problem i am having now is the images are still not being sent to the destiantion directory "images"

And the name of the images is still not being posted into the databse with the rest of the form data!

So basically am back to wear i started, i had the same problem when writing the form in an array in me other post thread,

Please dont give up on me now, ave been trying to fix this problem for a week,

Can anyone help

Thanks
Reply With Quote
  #7 (permalink)  
Old Nov 25th, 2007, 01:14
Reputable Member
Join Date: Dec 2005
Location: U.S.A.
Posts: 147
Thanks: 0
Thanked 3 Times in 3 Posts
Send a message via MSN to ScottR Send a message via Skype™ to ScottR
Re: Form submit

It looks like your overwriting the $target variable. Each time you use the assignment operator with $target it rewrites the data of that variable. Maybe try setting your directory, and then adding the filenames to it.
Code: Select all
//This is the directory where images will be saved 
$target = "images/"; 
$image1 = $target . basename( $_FILES['photo']['image_one']);
$image2 = $target . basename( $_FILES['photo']['image_two']);
$image3 = $target . basename( $_FILES['photo']['image_three']);
$image4 = $target . basename( $_FILES['photo']['image_four']);
You may also have the state the directory differently depending on where it resides in your document structure. I.E. ../images/ to move back one level in the document tree.

Make sense??
Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
submit many forms - auto submit the same form many times divs JavaScript Forum 0 May 24th, 2007 10:10
How to automate Form Submit??? TheGaffer8 Web Page Design 3 Apr 19th, 2007 11:08
how to submit form tobymather Web Page Design 13 Apr 17th, 2007 17:09
Form Submit button Help!!! Aaron1988 Web Page Design 2 Nov 25th, 2006 13:51
Submit 1 form to 2 different URLs alstefani Classic ASP 1 Aug 31st, 2005 05:26


All times are GMT. The time now is 20:48.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43