Webmaster Forums - Webmaster forum for HTML, PHP, ASP, CSS and more

Go Back   Webmaster Forums - Webmaster forum for HTML, PHP, ASP, CSS and more > Web Programming > PHP Development
User Name
Password

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 08-13-2006, 07:31 PM   #1 (permalink)
thezps
Junior Member
 
Join Date: Aug 2006
Posts: 2
Default Please take a look at this code

Hi, Im new to this list, and php in general. I am trying to set up a site that takes someone's address, lets them upload a picture, and then sends it to a MySQL database. If someone could offer some guidance on how to let users upload pictures, check to make sure its a picture file, rename it, and put it in a folder on my server in PHP I would be very grateful. I have a bigger problem right now though. Once someone hits 'submit' I send them to a page Im calling cleansubmit.php, which should fix the data, check that its clear, put it in the databases, and redirect the user to the main page. This is the code I've written for it so far.
<?php

ini_set('display_errors', 1);
error_reporting(E_ALL);

trim($_POST['name']
trim($_POST['adline1']
trim($_POST['adline2']
trim($_POST['city']
trim($_POST['zip']

nl2br($_POST['message']

stripslashes($_POST['name']
stripslashes($_POST['adline1']
stripslashes($_POST['adline2']
stripslashes($_POST['city']
stripslashes($_POST['zip']
stripslashes($_POST['message']

$error="" ;

if (ctype_digity($_POST['zip']==FALSE {
$error = "don't make up zip codes!" ;
}

if ($error == "") {
echo "vfg" ;
}else{
echo "$error <P> Please hit the back button to try again."
}

php?>


Obviously I havent gotten around to adding all of the features I've described. Still, when I bring this page up I just get a blank screen. When I go to view source all I get is this

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=windows-1252"></HEAD>
<BODY></BODY></HTML>


Why isnt the browser reading the php?
thezps is offline   Reply With Quote
Sponsored Links
Old 08-14-2006, 02:08 PM   #2 (permalink)
areamike
Junior Member
 
areamike's Avatar
 
Join Date: Aug 2006
Location: Cornfields of Indiana
Posts: 21
Default Re: Please take a look at this code

Do you have php installed and running? What type server, OS, Webserver?

paste this in notepad, then save as phpinfo.php (WITHOUT the .txt extension)

Code:
<?php phpinfo() ?>

then upload to your root directory of your website, and point your browser to
http://www.yoursite.com/phpinfo.php
Substituting yoursite.com with your site's domain name or IP address...

if you still get a blank page, probabailty is that php is not installed or configured to run, or not running on your server or webhost. If this is a webhost, you may want to contact them.

Also, you do not close PHP scripts with
php?>
only
?>
areamike is offline   Reply With Quote
Old 08-14-2006, 05:01 PM   #3 (permalink)
thezps
Junior Member
 
Join Date: Aug 2006
Posts: 2
Default Re: Please take a look at this code

php is definatly installed and working. Ive tried the phpinfo() thing a couple of times and done some hello worlds. It is my understanding that <? and <?php are both acceptable. I have updated the code a bit, fixed some obvious errors. Here is the new code...it still doesnt work

<html>
<body>

<?php

ini_set('display_errors', 1);
error_reporting(E_ALL);

trim($_POST['name']);
trim($_POST['adline1']);
trim($_POST['adline2']);
trim($_POST['city']);
trim($_POST['zip']);

nl2br($_POST['message']);

stripslashes($_POST['name']);
stripslashes($_POST['adline1']);
stripslashes($_POST['adline2']);
stripslashes($_POST['city']);
stripslashes($_POST['zip']);
stripslashes($_POST['message']);


$error="" ;

if ($error == "") {
echo "Thank you for using Pigeon Post. A pigeon has been dispatched to your local post office." ;
}else{
echo "$error <P> Your card was NOT sent. Please hit the back button to try again." ;
}


$time=int mktime ( [int hour [, int minute [, int second [, int month [, int day [, int year [, int is_dst]]]]]]] )


$link=
mysqli_connect ('localhost','root','google','PigeonPost');

$insert="INSERT INTO main
(time, name, adline1, adline2, city, zip, message)
VALUES ('$time','$_POST[name]', '$_POST[adline1']','$_POST[adline2]','$_POST[city]','$_POST[zip]','$_POST[message]' )";
mysql_query($insert);

$insert="INSERT INTO records
(time, adline1, adline2, city, zip)
VALUES ('$time', '$_POST[adline1]','$_POST[adline2]','$_POST[city]','$_POST[zip]')";
mysql_query($insert);

mysqli_close($link);


$time="";

php?>
</body>
</html>
thezps is offline   Reply With Quote
Old 08-17-2006, 03:19 AM   #4 (permalink)
saidev
Junior Member
 
Join Date: Aug 2006
Posts: 28
Default Re: Please take a look at this code

Like the last post said, close the script with ?> not php?> and yes, both <? and <?php works...most professionally done script I've see uses <?php

You say it still doesn't work? Is it still displaying as clear text?

Try do one step at a time, maybe get one of the POST and output it to the screen. Than move downwards on the code.

trim($text) does not change $text
PHP Code:
$trimedText trim($text); 
Same thing for stripslashes
How about this
PHP Code:
$name trim(stripslashes($_POST['name'])); 

Not sure about your server setting, but I see that you should use addslashes() instead of stripslashes if you are inserting those values into the db.

$error will always = ""; not sure what you are checking for...
PHP Code:
$error="" ;

if (
$error == "") {
echo 
"Thank you for using Pigeon Post. A pigeon has been dispatched to your local post office." ;
}else{
echo 
"$error <P> Your card was NOT sent. Please hit the back button to try again." ;


calling mktime()? where is the int hour, int minute and other variables coming from? If you just want the current timestamp, just do $time = mktime();

To upload image or files to the server, you must...
do
[HTML]
<form action="whatever.php" method="POST" enctype="multipart/form-data">
<input type="file" name="imgfile">
<input type='submit' value="upload">
</form>
[/HTML]

PHP Code:
//now the data...
$_FILES['imgfile'][]; //a 2d array can allow you access the files now 
Check out the link below for the $_FILES description...since I'm not allow to post url yet(still under 15 post), copy and past the link below
us3.php.net/manual/en/features.file-upload.php#features.file-upload.post-method

Hope this help.
saidev is offline   Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
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

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

Points Per Thread View: 1.00
Points Per Thread: 11.00
Points Per Reply: 5.00



» Sponsors

» Links

» Affiliates
Web Hosting
Online Backup Reviews
Marketing Find
Merchant Select
SiteMap Builder
Host Compare
Dedicated Servers

» Links

» Sports Network
Paintball Forum
Football Forum
Hockey Forum
Golf Forum
Boxing Forum
Lacrosse Forum
Baseball Forum
SnowBoarding Forum
Soccer Forum
MMA Forum


All times are GMT -4. The time now is 04:28 PM.



LinkBacks Enabled by vBSEO 3.0.0 RC8
Webmaster Forums