Help a newbi, ;)

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Maluendaster
Forum Contributor
Posts: 124
Joined: Fri Feb 25, 2005 1:14 pm

Help a newbi, ;)

Post by Maluendaster »

hey all, I'm a newbi in this world of PHP and this is my first post, and hopefully not the last.

My question is that I wanna make a form that can upload an image, risize it to a given width and height, rename the file with 5 random numbers and give and ID (those 5 random numbers)... Why do I wanna do this? , i want to create a script that can upload images to a wap enabled server, then from the cell phone, put in a form the 5 numbers and download the image...

Thanks in avance and I hope you can understand me..

Saludos desde Chile!

PS : I forgot to say, i have tried for a long time now with no success, searching google, reading tutorials, but nothing that can help me.
User avatar
shiznatix
DevNet Master
Posts: 2745
Joined: Tue Dec 28, 2004 5:57 pm
Location: Tallinn, Estonia
Contact:

Post by shiznatix »

upload the image, get the extension, create a new image from that image with the set height&width, then save the image as a random numer.

for the image stuff look up imagecreatefromgif(); and the sort. I hate that area of php so im not much help there

for the random number you can do somthing like this (quick and not the best but it will work).

Code: Select all

$a = rand(0, 9);
$b = rand(0, 9);
$c = rand(0, 9);
$d = rand(0, 9);
$e = rand(0, 9);

$num = $a.$b.$c.$d.$e;
Maluendaster
Forum Contributor
Posts: 124
Joined: Fri Feb 25, 2005 1:14 pm

Post by Maluendaster »

thanks man, i'll try to do something with that... thanks a lot...
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

don't forget to check if this "random" number already exists.. you don't want to wipe out an old one.. or do you?
Maluendaster
Forum Contributor
Posts: 124
Joined: Fri Feb 25, 2005 1:14 pm

Post by Maluendaster »

feyd wrote:don't forget to check if this "random" number already exists.. you don't want to wipe out an old one.. or do you?
right, thanks for that, if i ever finnish this script i'll post it here... ;)

Still studying what to do! ! :oops: I have absolutely no clue, but i think i'm in the right track...
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

..

Post by s.dot »

If it's a unique image name that you're looking for, dealing with number, why not use:

Code: Select all

$num = time();
This will provide you with a unique number every time (unless an image is uploaded at the EXACT same time, which is unlikely).
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

uh... it's actually quite possible.. given that the timestamp covers a full second. uniqid() may be a better choice.. but even then, you need to verify it doesn't exist already.
Maluendaster
Forum Contributor
Posts: 124
Joined: Fri Feb 25, 2005 1:14 pm

Post by Maluendaster »

ok, right now I have 2 files, the problem is that the variable $clave doesnt show in the pass.php file ....

wap.php

Code: Select all

<?
header("Content-Type: text/vnd.wap.wml");
echo"<?xml version="1.0"?>"; ?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN"
			"http://www.wapforum.org/DTD/wml_1.1.xml">
<wml>			
<card id="Descarga" title="The Chilean Sanitarium">
<do type="accept" label="Enviar">
<go method="post" href="pass.php">
<postfield name="wall" value="$clave"/>
</go>
</do>
<p>
ID
<input title="name" name="wall"/><br/>
</p>
</card>
</wml>
pass.php

Code: Select all

<?
header("Content-Type: text/vnd.wap.wml");
echo"<?xml version="1.0"?>"; ?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN"
			"http://www.wapforum.org/DTD/wml_1.1.xml">
<wml>		
<a href="http://www.metallica.com/wap/<?echo  $HTTP_POST_VARS&#1111;'clave'] ?>.jpg">Descargar Wallpaper</a>
</wml>
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

$clave is not set in wap.php... unless you have register_globals on (which isn't a good idea) or you include wap.php from another file, it won't exist.
Maluendaster
Forum Contributor
Posts: 124
Joined: Fri Feb 25, 2005 1:14 pm

Post by Maluendaster »

feyd wrote:$clave is not set in wap.php... unless you have register_globals on (which isn't a good idea) or you include wap.php from another file, it won't exist.
how do i set $clave...
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

http://php.net/variables

you will also need to actually have the output for $clave processed by php. The code you posted has $clave outside of php's parsing.
Maluendaster
Forum Contributor
Posts: 124
Joined: Fri Feb 25, 2005 1:14 pm

Post by Maluendaster »

i have no idea what to do next, can anyone please finnish or enlight me with something?
Post Reply