Current location: Hot Scripts Forums » Programming Languages » PHP » Simple uploading to database need help please


Simple uploading to database need help please

Reply
  #1 (permalink)  
Old 04-23-04, 11:28 AM
civrob civrob is offline
Newbie Coder
 
Join Date: Apr 2004
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Simple uploading to database need help please

Hiya Im trying to learn PHP and would just like to upload a form onto the database.

html form called form.html

----------------------------------------------------------------------
<html>
<head>
<title>form</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
<form action="upload.php" method="post" name="contact">
UserName<input name="UserName" type="text"></br>
Password<input name="Password" type="text"></br>
FirstName<input name="FirstName" type="text"></br>
Surname<input name="Surname" type="text"></br>
Title<input name="Title" type="text"></br>
DateOfBirth yyyyMMDD:<input name="DateOfBirth" type="text"></br>
Address<input name="Address" type="text"></br>
TelephoneHome<input name="TelephoneHome" type="text"></br>
TelephoneMobile<input name="TelephoneMobile" type="text"></br>
Email<input name="Email" type="text"></br>
Picture<input name="Picture" type="text"></br>
UserCredit<input name="UserCredit" type="text"></br>

<input type="submit" name="Submit" value="Submit"> <input type="reset">

</form>
</body>
</html>

----------------------------------------------------------------------
upload.php

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Upload</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
PHP Code:

<?php


$UserName
=$_POST['UserName'];
$Password=$_POST['Password'];
$FirstName=$_POST['FirstName'];
$Surname=$_POST['Surname'];
$Title=$_POST['Title'];
$DateOfBirth=$_POST['DateOfBirth'];
$Address=$_POST['Address'];
$TelephoneHome=$_POST['TelephoneHome'];
$TelephoneMobile=$_POST['TelephoneMobile'];
$Email=$_POST['Email'];
$Picture=$_POST['Picture'];
$UserCredit=$_POST['UserCredit'];

$link mysql_connect ("localhost""twenty" "123")
    or die(
"cannot connect to server");

$db mysql_select_db("twentyfourseven")
    or die (
"Cannot select the twentyfourseven database");

$query "INSERT INTO contacttable(UserName,Password,FirstName,Surname,Title,DateOfBirth,Address,TelephoneHome,
          TelephoneMobile, Email, Picture, Usercredit 
          VALUES('
$UserName','$Password','$FirstName','$Surname','$Title','$DateOfBirth','$Address','$TelephoneHome','$TelephoneMobile','$Email','$Picture',
'
$UserCredit)";

                
$result=mysql_query($query);
                
mysql_close(); 
?>

</body>
</html>
my problem is it works but when i goto command prompt to see if it has uploaded it says empty set (0.0sec), please any help wud be appriciated!

thanks

Last edited by civrob; 04-23-04 at 12:06 PM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #2 (permalink)  
Old 04-23-04, 11:47 AM
Trevor's Avatar
Trevor Trevor is offline
Wannabe Coder
 
Join Date: Jun 2003
Location: Denver, Colorado
Posts: 120
Thanks: 0
Thanked 0 Times in 0 Posts
Before we get too far into this, I have one question and one suggestion.

Question : Picture. Is this an actual picture. As in something you can work on in PhotoShop, or is it a picture name, or URL to a picture? Depending upon your intentions with this field, your form will need to be adjusted to handle binary uploads.

Suggestion : Check your submitted data. I can't say this enough. Check if for funky code, empty values, or anything else that might compromise your server and site.

Let's start with a response to the question. OK?
__________________
The Universe Our God, Nature Our Temple, Love And Duty Our Religion, Knowledge Our Happiness And Consolation, Death The Dissolution Of The Ego, And The Return To Eternity.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #3 (permalink)  
Old 04-23-04, 11:52 AM
civrob civrob is offline
Newbie Coder
 
Join Date: Apr 2004
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by Trevor
Before we get too far into this, I have one question and one suggestion.

Question : Picture. Is this an actual picture. As in something you can work on in PhotoShop, or is it a picture name, or URL to a picture? Depending upon your intentions with this field, your form will need to be adjusted to handle binary uploads.

Suggestion : Check your submitted data. I can't say this enough. Check if for funky code, empty values, or anything else that might compromise your server and site.

Let's start with a response to the question. OK?

I havent crossed the picture yet no clue how to do, it is just a char field for now.

do u mean echo my out put?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #4 (permalink)  
Old 04-23-04, 12:19 PM
civrob civrob is offline
Newbie Coder
 
Join Date: Apr 2004
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
solved it by

PHP Code:



$query 
mysql_query("INSERT INTO contacttable(UserName,Password,FirstName,Surname,Title,DateOfBirth,Address,TelephoneHome, TelephoneMobile,Email,Picture,Usercredit)".
         
"VALUES('$UserName','$Password','$FirstName','$Surname','$Title','$DateOfBirth','$Address','$TelephoneHome','$TelephoneMobile','$Email','$Picture','$UserCredit')"); 
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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 Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
PHP Form to update a MySQL database? Scoobler PHP 9 09-04-08 02:41 AM
Does anyone have a simple database access script? techknow ASP 3 04-19-04 01:21 PM
Need a simple uploading script DarkSamurai2003 Script Requests 2 11-21-03 05:59 AM
Share database over the internet nitinkedia PHP 0 07-11-03 01:22 AM


All times are GMT -5. The time now is 09:17 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.