The Grinding Shed: Php - The Grinding Shed

Jump to content

  • (3 Pages)
  • +
  • 1
  • 2
  • 3
  • You cannot start a new topic
  • You cannot reply to this topic

Php Please Help People?

#1 User is offline   Green Mamba Icon

  • Group: Members
  • Posts: 84
  • Joined: 10-February 04
  • Location:3rd World
  • Interests:The Symbiosis of Life & Death, Comics & Web Design

Posted 10 February 2004 - 10:27 AM

I started learning PHP last night. Got everything working, PHP, Apache, MySQL and then got going on some basics. Everything still going great until I try this

HTML Forms and PHP

It executes the form action, except it doesn't insert the form fields in the second page? I feel I need to solve this until I can go onto arrays.

Please Help People?
0

#2 User is offline   Alexander Icon

  • Group: Admin
  • Posts: 3,097
  • Joined: 13-June 02
  • Gender:Male
  • Location:Your girlfriend's thoughts
  • Your fuckin' daddy

Posted 10 February 2004 - 10:32 AM

Your server config probably has global variables turned off, which is good. You'll have to reference the passed variables using the global arrays - $_POST for a POST method form, $_GET for a GET method form etc.

In the example use $_POST['yourname'] instead of just $yourname. That should fix it. It's also good programming practice to know exactly where your variables are coming from.
It's not the houses, it's the spaces between the houses.
akpcep.com - Everything | alexanderking.co - Me
0

#3 User is offline   Green Mamba Icon

  • Group: Members
  • Posts: 84
  • Joined: 10-February 04
  • Location:3rd World
  • Interests:The Symbiosis of Life & Death, Comics & Web Design

Posted 10 February 2004 - 10:41 AM

Great. Knew I was asking that question at the right place. You'd think these tutorials would explain all that... ?

Any other good starting tips which I don't even know I should be thinking about yet?
0

#4 User is offline   Alexander Icon

  • Group: Admin
  • Posts: 3,097
  • Joined: 13-June 02
  • Gender:Male
  • Location:Your girlfriend's thoughts
  • Your fuckin' daddy

Posted 10 February 2004 - 10:57 AM

Hmmm.. loads really. Always use echo instead of print, unless you want to test if the action was successful. Print returns a boolean, whereas echo doesn't, which makes echo faster.

Oh, and when echoing things to the browser, only use double quotes if you're embedding variables in the string;

echo "this is a string containing a variable called $variablename";

otherwise:

echo 'this is a string without any vars in it, so php won't check it for them';

There's a lot of things like that which are generally good programming practice. But PHP is so damn easy it's hard to fuck it up to be honest.
It's not the houses, it's the spaces between the houses.
akpcep.com - Everything | alexanderking.co - Me
0

#5 User is offline   Green Mamba Icon

  • Group: Members
  • Posts: 84
  • Joined: 10-February 04
  • Location:3rd World
  • Interests:The Symbiosis of Life & Death, Comics & Web Design

Posted 10 February 2004 - 11:13 AM

Nice. I'll give it a try tonight. I've allocated two hours a night for studying until I can build a fully functional PHP Site with all the bells and whistles. I'm sure I'll be back for more wisdom.

Oh and you're talking to the person who inexplicably crashed his PC when installing drivers for a new mouse and then again when installing drivers for a CD Writer (Never under the influence though)
0

#6 User is offline   Alexander Icon

  • Group: Admin
  • Posts: 3,097
  • Joined: 13-June 02
  • Gender:Male
  • Location:Your girlfriend's thoughts
  • Your fuckin' daddy

Posted 10 February 2004 - 11:41 AM

Well, there's plenty of people here fluent in the dark art of the hypertext preprocessor so just shout up if you need any help.

I'm moving this topic btw.
It's not the houses, it's the spaces between the houses.
akpcep.com - Everything | alexanderking.co - Me
0

#7 User is offline   hollow Icon

  • Group: Members
  • Posts: 1,772
  • Joined: 27-August 01
  • Location:Newcastle upon Tyne (UK)

Posted 10 February 2004 - 05:57 PM

<?PHP
if($output)
{
?>

<p>For big chunks of html output, you can close and reopen the php tags,
which means that you don't have to be hassled backslashing all the damn speechmarks and such.</p>

<p>Also, keep your functions small, one loop or conditional to a function (or one of each). That's good practice in any language in my oppinion, but if taken too far it can slow things down slightly.</p>

<p>Oh, and put in explicit (\r\n) linebreaks at the end of echos, especially ones in loops. This will make the source more readable and help Netscape not fuck up your stylesheets.</p>

<?PHP
}
?>

This post has been edited by hollow: 10 February 2004 - 06:00 PM

0

#8 User is offline   Green Mamba Icon

  • Group: Members
  • Posts: 84
  • Joined: 10-February 04
  • Location:3rd World
  • Interests:The Symbiosis of Life &amp; Death, Comics &amp; Web Design

Posted 10 February 2004 - 07:54 PM

Hey guys, this is fucking great. After my innitial glitch, I made it through the first basic tutorial without any problems ... now for some more serious stuff.

Thanks
0

#9 User is offline   Green Mamba Icon

  • Group: Members
  • Posts: 84
  • Joined: 10-February 04
  • Location:3rd World
  • Interests:The Symbiosis of Life &amp; Death, Comics &amp; Web Design

Posted 11 February 2004 - 10:11 AM

I started reading Teach yourself PHP in 24 Hours. I just finished hour 4 and realised that PHP is to HTML what Math is to English (in dumbass terms). This should be a breeze (and a good chance to awaken my long dormant math skills).

4 hours to learn what a friggin Boolean is...

Anyways, can anybody explain (in dumbass :blink: ) what the purpose of Dynamic Variables is (or should I just wait and see later on)?

$user = "bob";
is equivalent to
$holder="user";
$$holder = "bob";
0

#10 User is offline   Alexander Icon

  • Group: Admin
  • Posts: 3,097
  • Joined: 13-June 02
  • Gender:Male
  • Location:Your girlfriend's thoughts
  • Your fuckin' daddy

Posted 11 February 2004 - 10:20 AM

Probably best to wait until later on, but in a nutshell:

Think of vars as key=value. a dynamic variable makes the value the key, essentially. They can be useful but there are other ways round the problems they solve if you're a beginner.
It's not the houses, it's the spaces between the houses.
akpcep.com - Everything | alexanderking.co - Me
0

#11 User is offline   hollow Icon

  • Group: Members
  • Posts: 1,772
  • Joined: 27-August 01
  • Location:Newcastle upon Tyne (UK)

Posted 11 February 2004 - 10:36 AM

I've never had to use dynamic variables... experimented with them from time to time, but i've never found a legitimate use for them that outweighed the confusion they cause. If I need this kind of thing, I prefer to use an array with named keys.
0

#12 User is offline   Alexander Icon

  • Group: Admin
  • Posts: 3,097
  • Joined: 13-June 02
  • Gender:Male
  • Location:Your girlfriend's thoughts
  • Your fuckin' daddy

Posted 11 February 2004 - 11:55 AM

The main occasion I find to use them is stuff like:

foreach ($_POST as $key=>$val){
      $$key=stripslashes($val);
}


Which is a nice quick way of formatting your POST vars before using em. Can also be occasionally useful when you pull an array out of a db.
It's not the houses, it's the spaces between the houses.
akpcep.com - Everything | alexanderking.co - Me
0

#13 User is offline   Green Mamba Icon

  • Group: Members
  • Posts: 84
  • Joined: 10-February 04
  • Location:3rd World
  • Interests:The Symbiosis of Life &amp; Death, Comics &amp; Web Design

Posted 11 February 2004 - 12:15 PM

Posting things like that before I have the knowledge to understand it isn't very motivational i.e. please adjust the level to that of the slowest student in the class?
0

#14 User is offline   Alexander Icon

  • Group: Admin
  • Posts: 3,097
  • Joined: 13-June 02
  • Gender:Male
  • Location:Your girlfriend's thoughts
  • Your fuckin' daddy

Posted 11 February 2004 - 12:26 PM

Sorry dude. In short - you don't need to know about dynamic variables.
It's not the houses, it's the spaces between the houses.
akpcep.com - Everything | alexanderking.co - Me
0

#15 User is offline   Alexander Icon

  • Group: Admin
  • Posts: 3,097
  • Joined: 13-June 02
  • Gender:Male
  • Location:Your girlfriend's thoughts
  • Your fuckin' daddy

Posted 11 February 2004 - 02:03 PM

They're also known as "variable variables". It's actually more useful than it sounds, IMO.
It's not the houses, it's the spaces between the houses.
akpcep.com - Everything | alexanderking.co - Me
0

  • (3 Pages)
  • +
  • 1
  • 2
  • 3
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users