|
|
|
|
![]() ![]() |
Apr 14 2007, 06:02 PM
Post
#1
|
|
|
Super Member ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Members Posts: 413 Joined: 4-October 06 From: Psychedelic Realms Member No.: 31,079 |
I just learned this simple method on how to use functions to combine two values from a form. First we create ourselves a simple POST form
CODE <form method="POST"> Name: <input type="text" name="nickname"> Location: <input type="text" name="location"> <input type="submit" value="Input"> </form> Now we add this php to that same file CODE <?php $nick = $_POST['nickname']; $location = $_POST['location']; function information($nick, $location){ echo 'My nick is '.ucfirst($nick).'<br>My location is '.$location; } information($nick, $location); ?> that code is similar to this one CODE <?php $nick = $_POST['nickname']; $location = $_POST['location']; function information($nick, $location){ return 'My nick is '.ucfirst($nick).'<br>My location is '.$location; } $combine = information($nick, $location); echo $combine; ?> It's up to you to decide which one to use And that is it. I really find this code quite useful for understanding functions in PHP. Hope it does the same for you. (here's the example) EDIT: Edited form as truefusion said below This post has been edited by matak: Apr 14 2007, 06:17 PM |
|
|
|
Apr 14 2007, 06:12 PM
Post
#2
|
|
|
Ephesians 6:10-17 ![]() Group: [MODERATOR] Posts: 1,918 Joined: 22-June 05 From: The World of Gentoo Member No.: 8,528 |
CODE <form action="<?php $PHP_SELF; ?>" method="POST"> If i'm not mistaken, you can do without the action="<?php $PHP_SELF; ?>" part since it'll be loading the same page. That is, CODE <form method="POST">
|
|
|
|
Apr 14 2007, 06:16 PM
Post
#3
|
|
|
Super Member ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Members Posts: 413 Joined: 4-October 06 From: Psychedelic Realms Member No.: 31,079 |
Thanks for the tip truefusion
|
|
|
|
![]() ![]() |
Similar Topics
|
Lo-Fi Version | Time is now: 13th October 2008 - 11:21 PM |