Welcome to HBH! If you had an account on hellboundhacker.org you will need to reset your password using the Lost Password system before you will be able to login.

PHP help!


ghost's Avatar
0 0

ok I'm really new to PHP, I like just started learning it about a week ago, anyway heres my problem:

I started working on the basic form with HTML you know the <form> tag. I wanted to make a form with HTML that you enter information and the information which is entered is processed to a PHP script, I used the POST method I'm sure all you know and used the $_POST array to get the names of the forms data. I enter the right names in the HTML form and the PHP $_POST array, this is what the HTML script looks like:

&lt;h4&gt;Tizag Art Supply Order Form&lt;/h4&gt;
&lt;form action=&quot;process.php&quot; method=&quot;post&quot;&gt; 
&lt;select name=&quot;item&quot;&gt; 
&lt;option&gt;Paint&lt;/option&gt;
&lt;option&gt;Brushes&lt;/option&gt;
&lt;option&gt;Erasers&lt;/option&gt;
&lt;/select&gt;
Quantity: &lt;input name=&quot;quantity&quot; type=&quot;text&quot; /&gt; 
&lt;input type=&quot;submit&quot; /&gt;
&lt;/form&gt;
&lt;/body&gt;&lt;/html&gt;

and this is the PHP script

$quantity = $_POST[&#39;quantity&#39;];
$item = $_POST[&#39;item&#39;];

echo $quantity . &#39;&lt;br&gt;&#39; . $item ;


?&gt;

but when I run the PHP on Apache server it comes up with this error:


**Notice:**Undefined index: on line 3

Now I don't know what's wrong but it might be the array, but of course please correct me if I'm wrong

one more thing when I'm testing out the HTML form and submit, it downloads the PHP file into notepad and opens it, not running the PHP script…

like I said I'm very new with PHP and this is just for testing. I have watch alot of tutorials on this subject but can't seem to get it to work.

thanks for your help!


ADIGA's Avatar
Member
0 0

when you run php on apache, does that mean when you run a php script or when trying to start apache???

cause from your problem it sems that php is not running on your computer, if it did the php file eill not download.

just to make life easier with those things … uninstall apache, php, mysql . then download xampp.

would work great for testing. almost no config is needed


stealth-'s Avatar
Ninja Extreme
0 0

Yes, like ADIGA said, your PHP code is perfectly fine. You must have misconfigured apache/PHP somewhere along the lines, or don't have PHP installed correctly.


ghost's Avatar
0 0

stealth- wrote: You must have misconfigured apache/PHP somewhere along the lines, or don't have PHP installed correctly. Or he's just running the PHP script without submitting through the form he created, meaning he's sending no values to it to be found… Maybe he thinks that what he's written is a program that needs to be running and listening for the information to handle it, fuck knows.


ghost's Avatar
0 0

COM- wrote: Or he's just running the PHP script without submitting through the form he created, meaning he's sending no values to it to be found…

I guess that was the first problem, thats why it was undefined becuase I went right the PHP server and tested it and didn’t submit the array data. thanks! :D

but I still don't know why it's downloading the source of the PHP script onto notepad and not running the script into the browser 0.o


j4m32's Avatar
Member
0 0

FACEPALM "… running the script into the browser"

PHP - Pre-Hypertext Processor - just by breaking down the name, "pre-hypertext" IE server side, before HTML output, some form of processing is/maybe performed.

Other languages such as: JSP (Java Server Page), ASP[X] (Active Server Page) and CFM (ColdFusion Markup Language) CGI extensions for Perl/Ruby and Python also work in the same vein.


Unless you are running this on some hosting which is unsuitable for PHP - in which case go and register at one of the many free PHP hosting sites.

As already stated by stealth- & ADIGA if you are developing from your PC with a local server, you need to have installed on your local machine/local server:

i)Apache ii)PHP (Maybe an SQL server if you are thinking of going on to doing some Database driven scripts)

More importantly, you need to configure Apache to handle PHP if you have not installed it or the installer could not automatically configure Apache to handle PHP scripts.

Since I don't know what OS you're running I've kept this guidance general.

Apache

If you installed PHP after apache, you need to make sure that it correctly automatically configured apache, go to your apache folder and look at:

conf/httpd.conf

...
LoadModule phpN_module &quot;[drive:]/path/to/php/phpNapache2[_2].[dll/so]&quot;
AddType application/x-httpd-php .php
...

PHP

PHP may need some configuration to run certain libraries you intend to use such as: database/graphics manipulation/encryption/encoding librarires.

This can all be found in the php.ini however be sure to check from PHPInfo for the path to your php.ini, usually in the same directory as your installation of PHP.

Jim


ghost's Avatar
0 0

j4m32 wrote: FACEPALM "… running the script into the browser"

PHP - Pre-Hypertext Processor - just by breaking down the name, "pre-hypertext" PHP - PHP: Hypertext Preprocessor; you know, a recursive abbreviation, kinda like GNU. It's sort of popular ;)


ghost's Avatar
0 0

so that's it! I had XAMPP installed and running but I wasn't running the HTML page into the server and therefore not running the PHP script into the server. HTML of course doesn't need a server but PHP does, so thats why HTML was working and PHP was not.

thank you all for replying and helping me.

Thanks a ton!;)