TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 05-14-2008, 02:03 AM   #1 (permalink)
The Wanderer
 
sacred_tinker's Avatar
 
Join Date: May 2008
Location: Singapore
Posts: 11
Thanks: 0
sacred_tinker is on a distinguished road
Default email fill in form help? PHP

Hey!

well, im very new to PHP and i know really nothing about it. I've recently started up my own website using html and now i've come to a point where im stuck! so far im not planning on remaking my site with PHP, instead i'd like to create a fill in form.

I'm almost done with one whole part of my website (my site is divided into three parts) but im having problems with my fill in form.

So i typed out the whole form (Tinka's Trinkets - (www.leopoldine.com/TinkasTinkets)), but then one of my teachers at school told me i needed to use PHP in order for it to work. BUT my teacher doesnt have enough time to help me, and im a total newbie at PHP and i don't get it. I've tried many different PHP forms (the ones that are pre-made) that you have to edit but none of them have worked...

can someone please give me an overview about how PHP works and what it is (in terms of email fill in forms)? so far the only thing i know is that there's alot to put in the code that doesnt necessarily come out when you "view source".

[i would like this form (that is to be filled in by any random person) to be sent to my email so that i know what orders people have placed]

please help me!

Last edited by sacred_tinker : 05-14-2008 at 12:21 PM. Reason: edited link to my order form
sacred_tinker is offline  
Reply With Quote
Old 05-14-2008, 03:01 AM   #2 (permalink)
The Addict
 
sarmenhb's Avatar
 
Join Date: Jan 2008
Location: los angeles
Posts: 309
Thanks: 44
sarmenhb is on a distinguished road
Default

hi, you got a long way to go lol,
if your really interested in learning php first let me explain to you what it is.

you know how you make a simple .html file well, when you load the page you can go to view -> source code and view the source code of the page that was created etc..

what php does is when you put your php code into this page when you go and try to view the source code you wont see it , thats because php in reality are coded language rules that are executed by php's engine which is apache.

in general php is a dynamic language, if you notice when i enter this reply for you and i press submit, the data i type goes straight into a database and the page retreives the data back again to the page and displays what im typing to you.

if you want to run php locally on your pc and your using windows XP, i would suggest you try out wamp which can be found at wampserver.com/en

install the program then if you setup the default directorys when installing , all of your php files should be placed in c:\wamp\www

this is your root directory meaning this is where you should place your php files.

now to do a sample run of php type this into a textfile (notepad)

Code:
<?php

echo "this is php"; 
?>
then save the file as index.php (rewrite the existing file if it exists)

then go into your browser and type http://localhost

this is how you access the root directory from your browser.

http://localhost/

as for working with forms let me show you an example and will try my best to explain

Code:
<html>
<head>
</head>
<body>
<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
FName: <input type="text" name="fname"><br/>
LName: <input type="text" name="lname"><br/>
<input type="submit" name="submit" value="submit"><br/>
</form>
</body>
</html>
all this peice of code does is submit the page and nothing really happends because you havent told it to do anything. now let me show you what you can do

you can either
1) save the data entered into a database like mysql
2) email a user with the information opened
3) display what the user typed on a new page.


Code:
<?php 
//checks to see if the submit button is pressed, if so then it processes what are in the curly brackets

if(isset($_POST{'submit'])) {

//you can check to see if values were entered into the textboxes like this

if(!$_POST['fname'] || !$_POST['lname']) { die('empty fields found'); }

//btw, these slashes are for entering your comments into the code so you know what you are coding.

//lets put these values into a database

include("your connection string to the database.php");
$save = mysql_query("insert into yourtable values('{$_POST['fname']},{$_POST['lname']})");

if($save) { exit('your data was saved'); } 





hope this helps..




?>
<html>
<head>
</head>
<body>
<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
FName: <input type="text" name="fname"><br/>
LName: <input type="text" name="lname"><br/>
<input type="submit" name="submit" value="submit"><br/>
</form>
</body>
</html>
i didnt check to see what i typed but if you would like help i can be reached on aim: sarmenhb
__________________
no signature set
sarmenhb is offline  
Reply With Quote
The Following User Says Thank You to sarmenhb For This Useful Post:
kcnuk (05-21-2008)
Old 05-14-2008, 06:19 AM   #3 (permalink)
The Addict
 
zxt3st's Avatar
 
Join Date: Apr 2008
Posts: 200
Thanks: 18
zxt3st is on a distinguished road
Default

well, as i can see based on what you post...you are a total newbie to PHP. Correct me if im wrong :). PHP is not that hard buddy all you need to understand is how the code works, how that pre-defined function works and why is that code always be used in doing such work(hope you get what i mean).

Example:

Code:
$sql ="INSERT INTO '".$table_name."'(name,add,age) VALUES (".$_POST['name'].",".$_POST['add'].",".$_POST['age'].")";
@mysql_query($sql,$link)or die("Error!");
you may ask @mysql_query btw,? how does it work? and what is die?is it the same with death? lol

thats what im pointing in above post :)

for now what i can recommend you is to read some articles in here. There are useful and very basic articles posted in the article section.

You could also do some readings in w3schools.com. It is where i first read about HTML and PHP as well as MySQL.

god bless!
zxt3st is offline  
Reply With Quote
The Following User Says Thank You to zxt3st For This Useful Post:
kcnuk (05-21-2008)
Old 05-14-2008, 12:18 PM   #4 (permalink)
The Wanderer
 
sacred_tinker's Avatar
 
Join Date: May 2008
Location: Singapore
Posts: 11
Thanks: 0
sacred_tinker is on a distinguished road
Default

t3st: yep! you're totally right. im a helpless newbie at this! >.<
i somewhat "get" what both of you mean but there's still a whole lot im totally clueless about.

sarmenhb: i downloaded the program. but what is it used for? is it for code checking? cause i have a folder on my desktop that i called "website" and its there that i keep all of my files for my website and then i upload them using CoreFTP. if i use the wamp program, isnt it gonna scatter all my website files into different parts of my computer?
and well, i dont know what "root directory" and "local host". im really really new to all of this.
PS i added you on msn.

i just figured the link i posted earlier on at the top of the page didnt work. just fixed it. :)
sacred_tinker is offline  
Reply With Quote
Old 05-14-2008, 02:22 PM   #5 (permalink)
The Acquainted
 
drewbee's Avatar
 
Join Date: May 2008
Posts: 175
Thanks: 9
drewbee is on a distinguished road
Default

Hi Tinker,

Yes PHP is not hard, *for someone who has programmed before*. It can be very difficult and challenging, but it is a very good language to be your first language. It is incredibly forgiving compared to alot of other languages, and thus will help you understand things more.

root directory ~ This is the top level directory from which all other directories stem. In windows, C:\ could be considered a root directory.

Local host ~ This references the current server you are on. If you have a database on your current server, you would access it by referencing 'localhost'
Send a message via AIM to drewbee
drewbee is offline  
Reply With Quote
Old 05-15-2008, 01:06 AM   #6 (permalink)
The Addict
 
sarmenhb's Avatar
 
Join Date: Jan 2008
Location: los angeles
Posts: 309
Thanks: 44
sarmenhb is on a distinguished road
Default

Quote:
Originally Posted by sacred_tinker View Post
t3st: yep! you're totally right. im a helpless newbie at this! >.<
i somewhat "get" what both of you mean but there's still a whole lot im totally clueless about.

sarmenhb: i downloaded the program. but what is it used for? is it for code checking? cause i have a folder on my desktop that i called "website" and its there that i keep all of my files for my website and then i upload them using CoreFTP. if i use the wamp program, isnt it gonna scatter all my website files into different parts of my computer?
and well, i dont know what "root directory" and "local host". im really really new to all of this.
PS i added you on msn.

i just figured the link i posted earlier on at the top of the page didnt work. just fixed it. :)
hi the program is has many uses its main purpose is to allow your computer to understand what php is because by default the only language it understands right now is html. if you put a php file on your pc it wont know what to do with it. what wamp server does is make your pc into a web server, just like when you go to yahoo.com or google.com etc.. those websites are running off of a computer just like yours but the only thing different about them from yours is that they have software being ran that allows people to access the webpage and view them. on wamp there is an option that can make your webpage accessible by anyone in the world just with one click.

btw, if you use msn my msn screen name is sarmenhb@hotmail.com and aim aka aol screen name is sarmenhb
__________________
no signature set
sarmenhb is offline  
Reply With Quote
Old 05-15-2008, 08:00 AM   #7 (permalink)
The Wanderer
 
sacred_tinker's Avatar
 
Join Date: May 2008
Location: Singapore
Posts: 11
Thanks: 0
sacred_tinker is on a distinguished road
Default

drewbee: for the local host thing, i bought my domain name and space using Godaddy... if that changes anything... >.<
sacred_tinker is offline  
Reply With Quote
Old 05-15-2008, 09:28 AM   #8 (permalink)
Jim
The Addict
 
Jim's Avatar
 
Join Date: Nov 2007
Location: the Netherlands
Posts: 281
Thanks: 2
Jim is on a distinguished road
Default

@drewbee:

Don't just assume the database is on the server itself. I have seen plenty of webhosts that didn't have it localhost.

@Sacred Tinker, you can of course ask Godadday for that :)

About WAMP, that's a little tool to install a webserver with PHP and MySQL support on your own computer. When using PHP you cannot run it just nativly in a browser like Internet Explorer. You need a server to progress the code and make the outcome of it. WAMP takes care of that.

When using WAMP to test your PHP applications, everything is localhost (you can assume that now) since it's on your own computer. (locahost basically means "this computer")

I highly advise you to read some basic PHP tutorials, mainly about form progressing and the basics. :)
__________________
Nunchaku! Who doesn't like martial arts? =)
Send a message via MSN to Jim Send a message via Skype™ to Jim
Jim is offline  
Reply With Quote
Old 05-15-2008, 08:09 PM   #9 (permalink)
The Frequenter
Newcomer 
 
xenon's Avatar
 
Join Date: Dec 2007
Location: Bucharest, Romania
Posts: 438
Thanks: 3
xenon is on a distinguished road
Default

to avoid confusion, Jim meant "processing" instead of "progressing". I really don't see where that came from, but what ever.
__________________
I have optimistic thoughts, even though sometimes (if not always) life's a bitch.
xenon is offline  
Reply With Quote
Old 05-15-2008, 08:33 PM   #10 (permalink)
Jim
The Addict
 
Jim's Avatar
 
Join Date: Nov 2007
Location: the Netherlands
Posts: 281
Thanks: 2
Jim is on a distinguished road
Default

// -- Offtopic: Ey, I'm a dutchman don't blame me!
__________________
Nunchaku! Who doesn't like martial arts? =)
Send a message via MSN to Jim Send a message via Skype™ to Jim
Jim is offline  
Reply With Quote
Old 05-16-2008, 07:46 PM   #11 (permalink)
The Frequenter
Newcomer 
 
xenon's Avatar
 
Join Date: Dec 2007
Location: Bucharest, Romania
Posts: 438
Thanks: 3
xenon is on a distinguished road
Default

// -- Offtopic as well: sorry if I offended you, I really didn't intend that
__________________
I have optimistic thoughts, even though sometimes (if not always) life's a bitch.
xenon is offline  
Reply With Quote
Old 05-18-2008, 05:01 AM   #12 (permalink)
The Wanderer
 
sacred_tinker's Avatar
 
Join Date: May 2008
Location: Singapore
Posts: 11
Thanks: 0
sacred_tinker is on a distinguished road
Default

otherwise, do you guys know how much it would cost to have someone convert my html form into a working PHP one?
sacred_tinker is offline  
Reply With Quote
Old 05-19-2008, 03:51 AM   #13 (permalink)
The Addict
 
zxt3st's Avatar
 
Join Date: Apr 2008
Posts: 200
Thanks: 18
zxt3st is on a distinguished road
Default

Quote:
Originally Posted by sacred_tinker View Post
otherwise, do you guys know how much it would cost to have someone convert my html form into a working PHP one?
its better to make you the one to convert it buddy :) Since you will learn a lot from it :P
zxt3st is offline  
Reply With Quote
Old 05-19-2008, 05:17 AM   #14 (permalink)
The Wanderer
 
sacred_tinker's Avatar
 
Join Date: May 2008
Location: Singapore
Posts: 11
Thanks: 0
sacred_tinker is on a distinguished road
Default

>.< but i don't have time! :(
sacred_tinker is offline  
Reply With Quote
Old 05-19-2008, 09:10 AM   #15 (permalink)
The Addict
 
zxt3st's Avatar
 
Join Date: Apr 2008
Posts: 200
Thanks: 18
zxt3st is on a distinguished road
Default

have a spare time on it buddy :) read during vacant, after reading do the works :)

it works fine in me :)
zxt3st is offline  
Reply With Quote
Old 05-20-2008, 01:42 AM   #16 (permalink)
The Addict
 
sarmenhb's Avatar
 
Join Date: Jan 2008
Location: los angeles
Posts: 309
Thanks: 44
sarmenhb is on a distinguished road
Default

Quote:
Originally Posted by sacred_tinker View Post
otherwise, do you guys know how much it would cost to have someone convert my html form into a working PHP one?
i'll do it for 15 bucks if its something small :p email me at sarmenhb@yahoo.com
__________________
no signature set
sarmenhb is offline  
Reply With Quote
Old 05-21-2008, 12:18 PM   #17 (permalink)
The Wanderer
 
sacred_tinker's Avatar
 
Join Date: May 2008
Location: Singapore
Posts: 11
Thanks: 0
sacred_tinker is on a distinguished road
Default

emailed you! :)
sacred_tinker is offline  
Reply With Quote
Old 05-21-2008, 05:04 PM   #18 (permalink)
The Frequenter
 
ReSpawN's Avatar
 
Join Date: Nov 2007
Location: Netherlands
Posts: 460
Thanks: 49
ReSpawN is on a distinguished road
Default

Quote:
Originally Posted by sarmenhb View Post
i'll do it for 15 bucks if its something small :p email me at sarmenhb@yahoo.com
Perhaps teach him for the money and let him do it. Then he'll get some out of all this.
__________________
"Life is a bitch, take that bitch on a ride"
Send a message via MSN to ReSpawN
ReSpawN is offline  
Reply With Quote
Old 05-28-2008, 05:44 AM   #19 (permalink)
The Wanderer
 
sacred_tinker's Avatar
 
Join Date: May 2008
Location: Singapore
Posts: 11
Thanks: 0
sacred_tinker is on a distinguished road
Default

*ahem*
"her"! :P
sacred_tinker is offline  
Reply With Quote
Old 05-28-2008, 05:58 AM   #20 (permalink)
The Frequenter
 
ReSpawN's Avatar
 
Join Date: Nov 2007
Location: Netherlands
Posts: 460
Thanks: 49
ReSpawN is on a distinguished road
Default

Quote:
Originally Posted by sacred_tinker View Post
*ahem*
"her"! :P
Excuse me, her! :P
__________________
"Life is a bitch, take that bitch on a ride"
Send a message via MSN to ReSpawN
ReSpawN is offline  
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
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


All times are GMT. The time now is 09:12 PM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design