Log in

View Full Version : My first PHP script thing.



Hitman
06-09-2006, 02:06 PM
I made a script thing:

http://team-x-labs.net/test/test.html

It outputs your name, and if you dont enter a name it says enter a name :p

What would be the next thing to make?

Jargit
06-09-2006, 02:08 PM
lol. i like it. Thats cool, i reckon u will get far :)

Its etremely simple yet i love it :P


EDIT: to make it more better, you could link it in with a register form for members. And it could be used quite like a newest member thing

Hitman
06-09-2006, 02:12 PM
Lol thanks, I've had an AWESOME idea of what to make, I'm gonna go and make it.

Jargit
06-09-2006, 02:23 PM
kk :):):):)

Hitman
06-09-2006, 02:59 PM
Right, I made an html code show thing. You enter an HTML code, it shows you what it will look like:

http://team-x-labs.net/test/test2.html

Make sure when using image, that its the full path, not just /image1.gif, make sure its http://yoururl.com/image1.gif ;)

If you find anything dodgey tell me.

Again simple, but hey :p Im not good at PHP (well not great).

Yeah
06-09-2006, 04:23 PM
LOL Tom good for your first try but thats soooo simple, would take like 30 seconds ;D

Hitman
06-09-2006, 04:25 PM
I know, I did say it was simple. I was showing my work. And yes, it did take around 30 seconds. Start on little things work your way up is what I'm doing. They'd be no point in me trying to code a members system would there?

Yeah
06-09-2006, 04:27 PM
You could do :p

Hitman
06-09-2006, 04:28 PM
Don't know enough, so they'd be no point.

Yeah
06-09-2006, 04:30 PM
Hm. If you say so :rolleyes:

Hitman
06-09-2006, 04:38 PM
Okay, I'll go code a member system, when I hardly know much.

Ryan, I'll be on MSN later.

ClubTime
06-09-2006, 04:40 PM
Woot that rocks. Its like one of them pointless but funny games on websites. :D

Hitman
06-09-2006, 04:42 PM
Woot that rocks. Its like one of them pointless but funny games on websites. :D

Lol, it's fun to mess with. :D Yeh, it's very pointless, but as I said fun to mess with. I'll see what else I can come up with that may be funny. :)

Yeah
06-09-2006, 04:53 PM
Its not exactly funny, well it didn't make me laugh anyway so you guys must have a weird sence of humour.

ClubTime
06-09-2006, 04:59 PM
it like playing this ('http://www.arcademee.com/Funny/Push-Thou-Button-166.html') game lol

Dentafrice1
06-09-2006, 06:24 PM
<?
$name = $_POST[name];
echo $name;
?>

Not hard :) Nice tho

Hitman
06-09-2006, 06:41 PM
<?
$name = $_POST[name];
echo $name;
?>

Not hard :) Nice thoLol :p Maybe when I learn more I'll be making better more useful things.


<form action="name.php" method="post">
Enter your name: <input type="content" cols="1" rows="10"
<input type="submit" value="Submit" name="Submit"
</form>

Save as test.html


<?php
$name = $_POST ['name'];
if ($code == " "){
echo "You didn't enter a name!";
} else {
echo "Your name is: ". $name ."";
}
?>

If anybody wants it, not that its much use lol. :P

Dentafrice1
06-09-2006, 06:45 PM
Not hard at all :)

Simple but yet very nice

EDIT: PHP is not supported in Sigs/Posts/Threads/User Titles :)

PixelResources
06-09-2006, 06:48 PM
Hi tom

You could use this as an addon



<?php
$name = $_POST ['name'];
if ($name == null){
echo "So you don't have a name, huh?";
} elseif($name == "Tom" && "tom" && "thomas" && "thommy") {
echo "Your name is the same as mine hehe.";
} elseif($name == "Ryan" && "ryan") {
echo "Your name is the same as my best mates!";
} else {
echo "OMG Your name is '.$name.' omgz...";
}
?>


Just something extra ^.^

Halting
06-09-2006, 06:50 PM
That's a little similiar to my first markup in PHP without a tutorial. Rather than your name, it allowed you to enter approximately 30 words and press submit. Then this would appear as the title on the success page.

That was a few months ago, and I'm very experienced now :)

Dentafrice1
06-09-2006, 06:50 PM
Nice little addon :)

test.html:
<form action="title.php" method="post">
Enter your name: <input type="content" cols="1" rows="10"
<input type="submit" value="Submit" name="Submit"
</form>

Title.php

<?
$title = $_POST[content];
?>
<title><? echo $title; ?></title>

PixelResources
06-09-2006, 06:51 PM
Lol :p

Halting
06-09-2006, 06:53 PM
I know?; Dentafrice.
:S

unlink(DHs/dentrafrice);

if only, eh?

PixelResources
06-09-2006, 06:56 PM
Dentafrice theres no need to echo it out in the Title simply use this;

<?
$title = $_POST[content];
?>
<title><? $title ?></title>

Just for something extra you could use

<?
$title = $_POST[content];
?>
<title><? $title ?></title>
<?
Then my script here
?>

Just for the hell of it.

Dentafrice1
06-09-2006, 06:58 PM
Im pretty sure you have to echo it..

PixelResources
06-09-2006, 06:59 PM
I don't think you do, but hey i sometimes make mistakes :p

Hitman
06-09-2006, 06:59 PM
Lol, yeh, you could use that (your first post), would be interesting.

You could make a cool quiz thing using this, you give them a question/riddle, they have to figure it out, if its right it takes them to the next question, if its wrong they have to try again! ^^

Dentafrice1
06-09-2006, 07:02 PM
What does that mean mynameisoli? WTH

Halting
06-09-2006, 07:03 PM
<?
$title = $_POST[content];
?>
<title><? $title ?></title>
<?
Then my script here
?>

That won't work. The simplest way to echo something through PHP markup in my knowledge is <?=$var;?>. For instance, <?=$title;?>. It saves you having to put a backward-slash before each and every speech mark. If you prefer to echo, you can always start your echos like so:

echo'<html></html>';

If you do it this way, you will not have to put a backward-slash before your speech marks. Instead, you will need to put a backward-slash before your apostrophes. For instance:

echo'<font class="header">Success!</font><br />We have successully truncated the table named $name. Don\'t forget to...';

EDIT: the function unlink is a function set in the PHP manual. It can be used to delete files from your server. For instance.

unlink(bg.jpg);

Hope this helps :)

Dentafrice1
06-09-2006, 07:07 PM
I know.. why did you want to unlink me? *** :p

PixelResources
06-09-2006, 07:07 PM
@Tom

enter.php



Riddle Question Here:<br><br>
<form action="name.php" method="post">
Enter the Answer Here:<br><input type="text" size="30" name="answer"><br><br>
<input type="submit" value="Submit" name="Is it right?"
</form>


quiz.php



<?php
$answer = $_POST ['answer'];
if ($answer == null){
echo "You think i am thick enough to let you not answer? No chance mate";
}elseif($answer == "ANSWERHERE") {
echo "OMG YOU GOT IT. WD M8.";
}else{
echo "Ha you cant even get it noob!";
}
?>

Hitman
06-09-2006, 07:10 PM
I made a few errors on mine, I was messing around with it and posted wrong bits xD I'm making something new now...

Halting
06-09-2006, 07:10 PM
nnvvvmm.

PixelResources
06-09-2006, 07:11 PM
Tom use mine :[

nets
06-09-2006, 07:15 PM
I made a script thing:

http://team-x-labs.net/test/test.html

It outputs your name, and if you dont enter a name it says enter a name :p

What would be the next thing to make?
I recommend reading some beginner's tutorials for PHP, and then creating some more advanced applications. Oh, and I suggest you use the "htmlentities()" function on data submitted by the user.


unlink(bg.jpg);
You need to encapsulate "bg.jpg" within apostrophes or quotation marks, as it's a string.

Halting
06-09-2006, 07:17 PM
That's right. I usually do $filetodelete = 'we.jpg'; unlink("$filetodelete");. You wouldn't need to surround the documents name with quotation marks or apostrophes if it didn't have a dot within it, but of course, it is almost required on every URL.

PixelResources
06-09-2006, 07:17 PM
@Joshua

OR htmlspecialchars($var)

:]

Really he has no need now as it doesnt integrate with any other pages which could cause trouble.

Hitman
07-09-2006, 07:24 AM
A new one, using the same idea: http://team-x-labs.net/test/form1.html

With an age, and type your name as Sparky. :p

PixelResources
07-09-2006, 03:31 PM
Well done:p

PixelResources
07-09-2006, 03:32 PM
Go on msn tom,

i also see your having trouble with: http://team-x-labs.net/test/form.php

Add a } to the end of script before the ?>

Hitman
07-09-2006, 03:41 PM
Hmm, the code seems fine to me :s


<?php
$name = $_POST ['name'];
$age = $_POST ['age'];
$location = $_POST ['location'];
if ($name == null){
echo "Enter a name!";
} else {
echo "Hmm, so your name is ".$name."";
if ($age == null){
echo "Enter a name!";
} else {
echo "you are ".$age." years old";
if ($location == null){
echo "Enter a location!";
} else {
echo " and you live in ".$location."... interesting!";
}
?>

It just doesn't work :(

PixelResources
07-09-2006, 03:45 PM
<?php
$name = $_POST ['name'];
$age = $_POST ['age'];
$location = $_POST ['location'];
if ($name == null){
echo "Enter a name!";
} else {
echo "Hmm, so your name is ".$name."";
if ($age == null){
echo "Enter a name!";
} else {
echo "you are ".$age." years old";
if ($location == null){
echo "Enter a location!";
} else {
echo " and you live in ".$location."... interesting!";
}
}
?>

Hitman
07-09-2006, 03:47 PM
<?php
$name = $_POST ['name'];
$age = $_POST ['age'];
$location = $_POST ['location'];
if ($name == null){
echo "Enter a name!";
} else {
echo "Hmm, so your name is ".$name."";
if ($age == null){
echo "Enter a name!";
} else {
echo "you are ".$age." years old";
if ($location == null){
echo "Enter a location!";
} else {
echo " and you live in ".$location."... interesting!";
}
}
?>


Parse error: syntax error, unexpected $end in /home/thebobb/public_html/team-x/test/form.php on line 19

Nope. :s

PixelResources
07-09-2006, 03:51 PM
<?php
$name = $_POST ['name'];
$age = $_POST ['age'];
$location = $_POST ['location'];
if ($age == null && $location == null){
echo "You left a field blank!";
} else {
echo "you are ".$age." years old and you live in ".$location."... interesting!";
}
?>


edit: also why are you defining the name variable but you dont use it?

you went the way complicated way round things >.>

Hitman
07-09-2006, 03:53 PM
<?php
$name = $_POST ['name'];
$age = $_POST ['age'];
$location = $_POST ['location'];
if ($age == null && $location == null){
echo "You left a field blank!";
} else {
echo "you are ".$age." years old and you live in ".$location."... interesting!";
}
?>

edit: also why are you defining the name variable but you dont use it?

you went the way complicated way round things >.>

I am using $name :s



if ($name == null){
echo "Enter a name!";
} else {
echo "Hmm, so your name is ".$name."";

>.>

PixelResources
07-09-2006, 03:56 PM
Ah yes :]



<?php
$name = $_POST ['name'];
$age = $_POST ['age'];
$location = $_POST ['location'];
if ($age == null && $location == null && $name == null){
echo "You left a field blank!";
} else {
echo "Hmm so your name is ".$name." you say?<br>You are ".$age." years old and you live in ".$location."... interesting!";
}
?>

Hitman
07-09-2006, 03:57 PM
LOL :( I just fixed it too :p


<?php
$name = $_POST ['name'];
$age = $_POST ['age'];
$location = $_POST ['location'];
if ($name == null && $age == null && $location == null){
echo "You missed something!";
} else {
echo "Hmm, so your name is ".$name.", you are ".$age." years old and you live in ".$location."... Cool!";
}
?>

:P xD

http://team-x-labs.net/test/form.html btw ;)

Edit: I also added bold tags.

Want to hide these adverts? Register an account for free!