| php پروگرامنگ php پروگرامنگ |
![]() |
|
|
LinkBack | موضوع کے اختیارات | موضوع کی درجہ بندی | ظاہری انداز |
|
|
#1 |
|
Member
اجنبی
تاریخ شمولیت: Jul 2007
عمر: 27
مراسلات: 75
کمائي: 415
شکریہ: 2
12 مراسلہ میں 28 بارشکریہ ادا کیا گیا
|
Okay till now we were working on single PHP pages and there was little interaction, take the example of the multiplication table, wouldn�t it be great if the user could enter which multiplication table he wanted and then we could give him that result.
As PHP is a server side scripting language user interaction can only occur when we send some info to the server, in turn the server processes our request and sends the requested page, thus we need to post (Send) data to the server. To illustrate I will show you an example: Let's build a multiplication table code where in the first page (ask_user.htm) we ask the user which table he wants and in the second page (table_results.php) we get that info and sends him the table. ask_user.htm کوڈ:
<html> <body> <form method=post action=table_results.php> Enter the multiplication table number <input type=text name=table size=2> <input type=submit> </form> </body></html> The PHP global array $_POST['variable name'] which is a built in super global array in PHP contains all the data that is posted by a form, you just need to pass your variable name to retrieve the data that you have posted. table_results.php کوڈ:
<html><body>
<?php
$cnt = 1;
$table = $_POST['table'];
while($cnt != 11)
{
echo "$table x $cnt = ". $table * $cnt;
$cnt++;
}
?>
</body></html>
Remember we have posted data to the server, see this line <input type=text name=table size=2> holds the value of the table. We have named the input field as table which now become our variable that stores the info. We retrieve the value of the table using $_POST['variable_name'] , in our case our variable that hold the value is table so we wrote the code $table=$_POST['table']; which retrieves the value and stores it in the $table variable. |
|
|
|
|
#2 |
|
Administrator
![]() ![]() تاریخ شمولیت: May 2007
عمر: 36
مراسلات: 11,361
کمائي: 171,667
شکریہ: 9,810
7,526 مراسلہ میں 22,598 بارشکریہ ادا کیا گیا
|
بہت عمدہ سبق ہے ۔ آج اس کو دہراوں گا۔
میں کچھ سوال پوچھنا چاہ رہا ہوں۔ 1- سپر ارائے کیا ہوتا ہے ؟ اور اسکا کیا مقصد ہو تا ہے؟ 2- اس روٹین کا کیا مطلب ہے کوڈ:
while($cnt != 11)
{
echo "$table x $cnt = ". $table * $cnt;
$cnt++;
}
والسلام
__________________
تم سپاہی نہیں ہو پیشہ ور قاتلو! |
|
|
|
|
#3 |
|
Senior Member
![]() ![]() |
سلام،
مذکورہ دھاگے کو بند کیا جارہا ہے کیوں کہ اس میں گذشتہ ایک مہینے سے کو ئی نیا مراسلہ نہیں ڈالا گیا۔ تما م مراسلے ارسال کرنے والے خواتین و حضرات کا شکریہ۔ وسلام، |
|
|
![]() |
| Tags |
| color, data, forms, global, great, php, آج, جواب, حضرات, خواتین |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| موضوع کے اختیارات | |
| ظاہری انداز | Rate This Thread |
|
|
Similar Threads
|
||||
| موضوع | موضوع شروع کیا | فورم | جوابات | آخری مراسلہ |
| Introducing PHP | مبشر | php پروگرامنگ | 7 | 28-12-07 06:28 PM |