Jump to content

PHP - my first hour


Aquachip

Recommended Posts

Hi!

 

I decided to take up learning PHP an hour ago. WOW its a powerful language.

 

The reason I decided to take it up is because I need to create a database for my website.

I am reading allot about PHP going hand in hand with MySQL, but I don't believe its necessary to use MySQL.

 

So, I started reading official introduction over at the PHP website.

 

Being someone with A.D.D, I tried so hard not to deviate, but couldn't help myself and started experimenting with code.

 

Using the tutorial guideline, I created this:

 

index.html

<?php

echo "test";

echo $_SERVER['HTTP_USER_AGENT'];

?>

<form action="action.php" method="post">

<p>Enter value: <input type="text" name="value" /></p>

<p><input type="submit" /></p>

</form>

 

action.php

<?php echo htmlspecialchars($_POST['value']); ?>

 

Then when mass A.D.D kicked in, I tried to guess other 'instructions' and did this:

action.php

<?php if ($_POST == ['1']) {echo "2"};

But I got a parse error.

 

Its pretty obvious what I want to do, so I won't state the obvious.

 

What I do need to learn is to create a search page for a website using radio box selections with the form POST, then PHP searches a database ("somedir/file.list")in a group list, and if the selected is in that group, then the website outputs some HTML or I guess the selection choices.

 

I can do it in python, so I am positive it can be done in PHP.

 

pro-airportpatdown = [party1, party4, party7]

anti-taxraise = [party5 [party9, party9]

neutral-iraqwar [party1 [party3]

 

Then I want something like

If question1 input in "pro-airportpatdown' then echo "Results:" then output = "/var/www/website1/partylist/party1.html" "/var/www/website1/partylist/party4.html" "/var/www/website1/partylist/party7.html"

 

Get what I mean?

 

I don't have the time do read the entire documentation now, I will do it next week when I have time, but just to give me an example of what I should expect, how can this be done?

 

 

Oh God, all these fantastic PHP ideas are coming to my head. I actually have a head ache!

 

 

Thanks!

Link to comment
https://forums.phpfreaks.com/topic/243501-php-my-first-hour/
Share on other sites

Awesome! The answer I was looking for was:

 

<?php if ($value = "1") {echo "2";}

?>

 

Is PHP the most powerful and popular server-side scripting language?

You probably want (==):

 

A single equals sign assigns a value, two will compare, 3 will compare values as well as types.

Link to comment
https://forums.phpfreaks.com/topic/243501-php-my-first-hour/#findComment-1250351
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.