Need help on HTML Code

FroztSpectre

Arch-Supremacy Member
Joined
Dec 7, 2007
Messages
15,275
Reaction score
197
Background:
I've attempting to create a simple website whereby the user can register and login with his account.
Then the user can upload "items" into the website. The user would need to input the item subject, description, tags, description as well as the image file.

After uploading, he will be able to see his "items" inside the Items Homepage. It will consist of a link to show the Item's Subject, a link to let the user edit the item details, as well as the image.

Here comes the problem, the user might upload a 800x600 picture. Then the item homage would display the 500x500 picture.

If i were to force resize it to 250x250, it would look very distorted... If the image was 50x100, forcing resize to 250x250 would look even more distorted.

So i was wondering, if there is any way to check for the image's dimension. If the dimension is above 300x300, the image would be resized (according to ratio), to below 300x300. If the dimensions is below 300x300, it would not resize the image.

One of the ways which i thought of is Thumbnails, or something like the current HardWareZone's feature.
 

xinus84

Senior Member
Joined
Sep 26, 2003
Messages
1,605
Reaction score
0
which programming language are you using? If using php, it has an imageresize module to resize your images as thumbnail. Google for the codes to resize proportionally.
 

FroztSpectre

Arch-Supremacy Member
Joined
Dec 7, 2007
Messages
15,275
Reaction score
197
Hmm thanks.

Another question

1) I'm using 2 forms to let the user Tag his item.
First one would be checkboxes comprising of default tag values.
Second one would be a textbox, the user could input his own tag values seperated by a comma. Then, i would explode the textbox so that it becomes an array, then i will array_merge it together with the checkboxes. Then i implode again... to make them all into an array....
Lastly, after uploading, it will display all the tags in checkboxes.

Here's my current code

if (isset($_POST['tags'])) {
$tags = $_POST['tags'];
$tags1Empty = false;
} else {
$tags = array();
$tags1Empty = true;
}

if (!empty($_POST['tagstring'])) {
$tagstring = $_POST['tagstring'];
$tags2 = explode(',', $tagstring);
$tags2Empty = false;
} else {
$tags2 = array();
$tags2Empty = true;
}

if ($tags1Empty && $tags2Empty == true){
$okay = false;
echo '<h3><font color="red">Error!</font><br /></h3>';
echo '<p><font color="red">Please Ensure That There Is At Least One Tag!</font></p>';
}

$allTags = array_merge($tags, $tags2);
$implodeTags = implode("," , $allTags);

Now, the problem is,
If the user spams ",,,," in the textbox, there will be empty checkboxes....

Sounds a little confusing, i'll upload some pictures soon.

Edited:
Pictures are up
ZoHTY.png

cLyNV.png
 
Last edited:

etherealism

Senior Member
Joined
Jul 17, 2006
Messages
2,258
Reaction score
0
after
$tags2 = explode(',', $tagstring);
add
$tags2 = array_filter($tags2);
to remove the empty elements.

but i sense another problem. seems like you haven't accounted for the user keying in tags that already exist.
 

FroztSpectre

Arch-Supremacy Member
Joined
Dec 7, 2007
Messages
15,275
Reaction score
197
after
$tags2 = explode(',', $tagstring);
add
$tags2 = array_filter($tags2);
to remove the empty elements.

but i sense another problem. seems like you haven't accounted for the user keying in tags that already exist.

Yeh....
Any way to solve that problem too?
=(

Edited:
Hmmm, array_filter($tags2); doesn't work for me.
Spamming commas still result in creating checkboxes.

Heres the link to the website.
http://1003485h-a2.0fees.net/

Username: testingaccount
Password: 123321

Alternatively, you can just create a account there urself. Note though, i didn't change the password to hash codes, so you guys better anyhow input things for registeration.

Edited 2:
THANKS! Working Already!
I added the array_filter inside the page that displays the array instead :p
 
Last edited:

saysuzu

High Supremacy Member
Joined
Oct 31, 2007
Messages
27,562
Reaction score
2
by right, you shouldn't allow users to input the delimiter themselves; this is a poor design example

not saying that you sux or or what la, but if this's just a schoolwork, then ok la, i'm fine with it, because last time i do that also

you should instead implement jquery/javascript to allow users to dynamically add checkboxes on a link click or something like that
 

FroztSpectre

Arch-Supremacy Member
Joined
Dec 7, 2007
Messages
15,275
Reaction score
197
by right, you shouldn't allow users to input the delimiter themselves; this is a poor design example

not saying that you sux or or what la, but if this's just a schoolwork, then ok la, i'm fine with it, because last time i do that also

you should instead implement jquery/javascript to allow users to dynamically add checkboxes on a link click or something like that

Requirement of Assignment =P
 

soarer

Banned
Joined
Jun 23, 2004
Messages
36,745
Reaction score
1,596
These codes are not html.

PHP:
after
 $tags2 = explode(',', $tagstring);
 add
 $tags2 = array_filter($tags2);
 to remove the empty elements.
 

twinbaby

Supremacy Member
Joined
Jul 8, 2014
Messages
5,417
Reaction score
1,499
See comment in <<>>

Background:
I've attempting to create a simple website whereby the user can register and login with his account.<<on registration need to store details in database with insert statement,on login system need to verify if user exist in the database or not & and also compare the password>>

Then the user can upload "items" into the website. The user would need to input the item subject, description, tags, description as well as the image file.
<<Specific the maximum file size and create a folder to store the images>>

After uploading, he will be able to see his "items" inside the Items Homepage.<<specify the image size by width and height>> It will consist of a link to show the Item's Subject, a link to let the user edit the item details, as well as the image.<<create a seperate page to let user edit the details and save and go back>>

Here comes the problem, the user might upload a 800x600 picture. Then the item homage would display the 500x500 picture.

If i were to force resize it to 250x250, it would look very distorted... If the image was 50x100, forcing resize to 250x250 would look even more distorted.

So i was wondering, if there is any way to check for the image's dimension. If the dimension is above 300x300, the image would be resized (according to ratio), to below 300x300. If the dimensions is below 300x300, it would not resize the image.<<as mentioned by xinus84 use a imageresize_module or search for code that resize the image with balance,or you can use library like zen_photo>>

One of the ways which i thought of is Thumbnails, or something like the current HardWareZone's feature.
 
Last edited:

davidktw

Arch-Supremacy Member
Joined
Apr 15, 2010
Messages
13,547
Reaction score
1,301
Funny a champion digging up a 3 years old thread.. duh.
 
Important Forum Advisory Note
This forum is moderated by volunteer moderators who will react only to members' feedback on posts. Moderators are not employees or representatives of HWZ Forums. Forum members and moderators are responsible for their own posts. Please refer to our Community Guidelines and Standards and Terms and Conditions for more information.
Top