Forum     

Go Back   Digit Technology Discussion Forum > Portables, Peripherals and Electronics > QnA (read only)
Register FAQ Calendar Mark Forums Read

QnA (read only) Mods please help transfer the contents of this forum to proper sections. :)


 
 
LinkBack Thread Tools Search this Thread Display Modes
Old 31-07-2005, 10:33 PM   #1 (permalink)
Human Spambot
 
tuxfan's Avatar
 
Join Date: Feb 2004
Location: Mumbai
Posts: 2,653
Default PHP & HTML forms - Pl help resolve basic problem


I am getting an error in PHP. What's wrong? Its on Win98SE, Apache 2.0.54, PHP 5.

Here's forms.htm file
Code:
<html>
<head></head>
<body>
  <form action="forms.php" method="GET">
    <input type="text" name="user">

    <textarea name="address" rows="5" cols="40"></textarea>

    <input type="submit" value="Submit">
  </form>
</body>
</html>
Here's the forms.php file
Code:
<html><head></head>
<body>
  <?php
    print "Welcome $user
";
    print "Your address is:$address";
  ?>
</body>
</html>
Here's the error that I get The URL of the browser window is http://localhost/forms.php?user=tuxfan&address=Mumbai
Quote:
Notice: Undefined variable: user in D:\apacheww\forms.php on line 4
Welcome

Notice: Undefined variable: address in D:\apacheww\forms.php on line 5
Your address is:
tuxfan is offline  
Advertisements. Register and be a member of the community to get rid of them.
Advertisement

Old 31-07-2005, 10:46 PM   #2 (permalink)
In Pursuit of "Happyness"
 
kalpik's Avatar
 
Join Date: May 2005
Location: New Delhi
Posts: 3,432
Default

Hi!

Try this:
Code:
<html><head></head>
<body>
  <?php
    $user=$_GET['user'];
    $address=$_GET['address'];
    print "Welcome $user
";
    print "Your address is:$address";
  ?>
</body>
</html>
Hehe, if im not wrong, i was the one who got u started wid PHP (if u remember that is )

One suggestion: Go through the documentation at http://www.php.net You will find everything related to PHP there.

No book is better than that!
kalpik is offline  
Old 31-07-2005, 10:53 PM   #3 (permalink)
In Pursuit of "Happyness"
 
kalpik's Avatar
 
Join Date: May 2005
Location: New Delhi
Posts: 3,432
Default

Another solution. You dont need another html file for this!

Code:
<html><head></head>
<body>
  <?php
    $submit=$_GET['submit'];
    if(isset($submit))
    {
         $user=$_GET['user'];
         $address=$_GET['address'];
         print "Welcome $user
";
         print "Your address is:$address";
    }
    else
    {
           ?>
           <form action="forms.php" method="GET">
              <input type="text" name="user">

              <textarea name="address" rows="5" cols="40"></textarea>

              <input type="submit" value="Submit">
           </form> 
           <?php
    }
  ?>
</body>
</html>
Havent tested it, maybe a typo here n there!
__________________
Whenever you find yourself on the side of the majority, it is time to pause and reflect. - Mark Twain
kalpik is offline  
Old 01-08-2005, 04:18 PM   #4 (permalink)
Human Spambot
 
tuxfan's Avatar
 
Join Date: Feb 2004
Location: Mumbai
Posts: 2,653
Default

hey kalpik, thanks It worked. I would have PMed you if I wouldn't have got my answer in 24 hours I know you gave the last push required for me to get started on PHP.

I can understand what you are doing in the new forms.php file. The forum submission and processing is happenning in the same file depending on whether the submit button has called the page or its just loaded in the borwser through a link (or directly). Thanks for the tip

Actually, I have copied and pasted the code from an e-book. It gave errors. I checked another e-book, syntax looked right. I opened PHP manual, syntax still looked right :roll: So I was stumped. I even tried $_GET but it didn't work, may be I used $GET and missed out the underscore.

BTW, I am enjoying PHP
__________________
:: Free hosting and free domain names available in special cases. Conditions apply ::
tuxfan is offline  
Old 01-08-2005, 06:10 PM   #5 (permalink)
In Pursuit of "Happyness"
 
kalpik's Avatar
 
Join Date: May 2005
Location: New Delhi
Posts: 3,432
Default

Sure anytime buddy! PHP really IS amazing.
Im actually doing training in TATA Infotech nowdays. Working on some JSP project, so got a chance to learn JSP too. But believe me JSP is NOTHING compared to PHP!

And u guessed right about what im doing in the new forms.php. I knew u were smart enough to figure that out urself, thats why didnt explain

And once again im saying that nothing beats the original PHP Manual from http://php.net. I've downloaded the many HTML files version. It is updated most frequently.

And if any other help required, ill be more than glad to help (if i can help that is!). Hehe...

Take care!
__________________
Whenever you find yourself on the side of the majority, it is time to pause and reflect. - Mark Twain
kalpik is offline  
Old 01-08-2005, 07:11 PM   #6 (permalink)
sunnydiv
Guest
 
Posts: n/a
Default

hey tuxfan u r using a crappy server

use apache with XAMPP ur first script works fine
 
Old 01-08-2005, 08:29 PM   #7 (permalink)
In Pursuit of "Happyness"
 
kalpik's Avatar
 
Join Date: May 2005
Location: New Delhi
Posts: 3,432
Default

But that is not how the standards go! If u are learning something, learn it according to standards. Good programming practice is also an important thing.

And how dare u call Apache a crappy server!? Hehe its the most popular server on the internet!
__________________
Whenever you find yourself on the side of the majority, it is time to pause and reflect. - Mark Twain
kalpik is offline  
Old 02-08-2005, 12:22 AM   #8 (permalink)
sunnydiv
Guest
 
Posts: n/a
Default

m not calling apache the crappy one, even i use it, i am callin it a crappy package
 
Old 02-08-2005, 12:42 AM   #9 (permalink)
In Pursuit of "Happyness"
 
kalpik's Avatar
 
Join Date: May 2005
Location: New Delhi
Posts: 3,432
Default

Oh! You talking about PHP+Apache+MySQL packages?
Well IMO, manual installation is the best, and i think Tuxfan did that only! Lol...
__________________
Whenever you find yourself on the side of the majority, it is time to pause and reflect. - Mark Twain
kalpik is offline  
Old 02-08-2005, 12:43 PM   #10 (permalink)
Human Spambot
 
tuxfan's Avatar
 
Join Date: Feb 2004
Location: Mumbai
Posts: 2,653
Default

Yes kalpik you are right. I did manual installtion. I used (and have saved) that thread in Tutorials section where Deep posted the details and you fine tuned them. Thanks so much for your help.

I will surely get in touch with you as and when I am stuck. I now have a reliable source for all PHP difficulties. I will not lose that source so easily

sunnydiv, try out the manual installtion. Its not difficult at all!! Refer to that thread in Tutorials. Deep and kaplik have really made it easy. I did it in first shot!! So can you

I have always preferred some control over what I am doing and don't rely on automation too much. Nothing is ever automatic!! Someone has done it for you and therefore it looks automatic. Why not find out how he has done it?

Necessity is the mother of invention
Inquisitiveness is the mother of knowledge about that invention
tuxfan is offline  
 

Bookmarks

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

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


 
Latest Threads
- by Krow
- by abhidev
- by topgear
- by clmlbx

Advertisement




All times are GMT +5.5. The time now is 07:04 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.

Search Engine Optimization by vBSEO 3.3.2