Jump to content

Bloodrun

Member
  • Posts

    18
  • Joined

  • Last visited

  • Donations

    0.00 USD 
  • Country

    United States

Posts posted by Bloodrun

  1. What you could do, is have the checkbox visible at all times, but only able to use when option one has been picked by using a javascript code, such as this:

    function updatefields(){
    if (document.getElementById("selectedProd").options[document.getElementById("selectedProd").selectedIndex].value=='code1')
    {
    document.getElementById("checkbox").disabled=false;}
    else{
    document.getElementById("checkbox").disabled=true;
    }
    }

    <input type="checkbox" name="checkbox" id="checkbox"/>

    Hoped that helped.

  2. Okay I am using this tutorial:

    http://evolt.org/php_login_script_with_remember_me_feature?

    On creating a login/registration page.

    The only thing is that it doesn't come with a user id variable, and I would like to know how to add it, in both the PHP coding and the Database, now I believe this is how it should be added to the database:

    CREATE TABLE IF NOT EXISTS `users` (
    `id` int(10) NOT NULL auto_increment,
    `username` varchar(30) NOT NULL default '',
    `password` varchar(32) NOT NULL default '',
    PRIMARY KEY (`id`)
    ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=4;

    But im not sure how to add it to the PHP at all.

    Now, I have found several other tutorials that have a id variable with it, but none of them allow me to incorporate my pages with it the way I like.

  3. Bloodrun,

    After looking at your code, I have to tell you that you've got quite a bit of learning to do before you continue coding something as complex as this, especially since you're a beginner at PHP. I suggest starting off small, maybe with a simple website just to get to know PHP.

    The reason your background image isn't showing up is because you're using the same $image variable to create and display multiple images in your code. This will result in only the last image in your code being parsed and displayed. What you really need to do is, first of all, is use a different variable. Once you have all of these different variables with different images, you'll have to merge all of the images into a single one; this is done with the imagecopymerge function.

    As well, the syntax in most of your code is incorrect, but I, personally, cannot take the time to fix it because I am not quite sure what you are trying to do and it would also defeat the purpose of you learning PHP. Like I mentioned, you have to start off small and work your way up; you can't start midway and expect everything to work at once.

    Unfortunately, this is where I'm going to stop. You've got the basics of it. Now it's all a matter of browsing the http://www.php.net and learning about all of the functions that are a part of the GD library.

    Cheers and good luck,

    Lol, I wondered when this was gonna pop up.

    Alright, well thanks for the help.

  4. Hmmm... You have two options:

    First, you can use that code and output an error to the user if the inputted characters are more than your limit using an if statement. Otherwise, you can just truncate the inputted text using another PHP function I'll let you look up.

    Yeah I figured that, but making a set character limit wont let me use the wrap code. So i just kept the wrap code and lowered the text size.

    But I have another question. How come when ever I try to use an image, like if I wanted to have the option for the user to have an icon. It always makes that image the background =/ How come? It's getting really annoying..

    There are a few reasons for this. It would help if you posted your modified code so I could look at it and tell you why.

    Alright I sent it to you in a PM

  5. Hmmm... You have two options:

    First, you can use that code and output an error to the user if the inputted characters are more than your limit using an if statement. Otherwise, you can just truncate the inputted text using another PHP function I'll let you look up.

    Yeah I figured that, but making a set character limit wont let me use the wrap code. So i just kept the wrap code and lowered the text size.

    But I have another question. How come when ever I try to use an image, like if I wanted to have the option for the user to have an icon. It always makes that image the background =/ How come? It's getting really annoying..

  6. =/

    I know the number of characters I want for a single. But the problem is, that if the group of text is long enough, it will just keep doing down. and that ruins what im trying to do =/

    You can always limit the number of characters someone submits. See an example here: http://www.webmasterworld.com/forum88/7649.htm

    Hmm, alright, the code when I put it into my PHP it doesn't work, I don't know where to put it.

  7. Oh, heres the code Im using:

    <?php
    $text = "A very long woooooooooooord.";
    //8 is the limit of characters, '\n' is the breaking method, and false means if it was a word being cut, the word would stay whole instead.
    $newtext = wordwrap($text, 8, "\n", false);

    echo "$newtext\n";
    ?>

    That's the only way I ever did it. :( The trick is to find the correct limit for the number of characters you want on a single line.

    =/

    I know the number of characters I want for a single. But the problem is, that if the group of text is long enough, it will just keep doing down. and that ruins what im trying to do =/

  8. Hmm, okay well I have checked www.php.net

    And I have gotten a code for textwrapping, but, that Code doesn't resize the text for the more words you type in. Would you happen to know how to do that?

    Ill try to be more clear.

    So, here's a sentence or two:

    I went to the market to buy Lucy Sue a show. When I got there, the market was closed.

    The code I found for text wrapping does this (Depending on the amount of characters I choose):

    I went to the marker to

    buy Lucy Sue a show.

    When I got there, the

    Market was closed.

    Now, that would work, if I had a restriction on the amount of characters someone could type in. But I don't want the restrictions. Thus making this code invaluable to me..

    Oh, heres the code Im using:

    <?php
    $text = "A very long woooooooooooord.";
    //8 is the limit of characters, '\n' is the breaking method, and false means if it was a word being cut, the word would stay whole instead.
    $newtext = wordwrap($text, 8, "\n", false);

    echo "$newtext\n";
    ?>

  9. The problem's not with your code, it's with your images. Only sample_card.png is a valid PNG file; the others are just JPEG files with a PNG file extension. You have to convert them to valid PNG files in order to avoid having to edit the code at this point. The GD library in PHP expects a PNG image when you call imagecreatefrompng, otherwise it spits out a useless "error" like the one you're getting.

    Ohh, I forgot, I was doing several things when I was uploading them, and I thought I had converted them.

    Thanks for that, and um.. *cough* yeah, thanks. =D

  10. Can you post a screenshot of what it's giving you? I don't really understand what you mean by it giving you a "link to the page as an image."

    When, I fill out the form, and leave the select box alone, or choose Home (which is the default) it works, but none of the others.

    Now if I did this correctly, it will show the screen shot, That link that you see, is in, it's just hard to tell in the screen lol.

    post-236414-1237425252_thumb.jpg

  11. The easiest way to find the full path is to create a PHP file with the following in it and browsing to it:

    <?php phpinfo(); ?>

    Look under SCRIPT_FILENAME for the full path to your sig.php file and you'll be able to figure everything else out from there.

    Okay well i did all that, and it's still just giving me the link to the page as an image. =/

  12. OK, first of all, /full/path/to should be replaced with the actual full path to the file. This also applies to your font file as I'm pretty sure you don't have a fonts directory in the root of your filesystem (most likely a subdirectory of some other directory).

    For example, the full path to the font file on my server is: /home/username/website/sigs/verdana.ttf

    The same thing applies to your images (e.g., /home/username/website/sigs/background.png).

    Remember, this is specific to the server YOU are on, so you have to find this information (assuming you're running this script on a Linux server); the path would of course be different on a Windows server.

    oh lol.. I feel stupid now, I was thinking "/full/path/to/" was a code, I should've known..

    Lol ok well, right now I am using a free server, so would I actually need the "/home/username/" part?

    Okay.. yeah it's still not working =/

  13. I use http://www.php.net to read up on PHP.

    As for your problem, what types of images are you using (i.e., JPEG, PNG, GIF, etc.)? Did you use my exact code or only make changes to yours? Can you post all of your code if it's different than mine so I can check to see what the problem is?

    They are all PNG, and here is all of my code:

    <?php
    $name = $_REQUEST['name'];
    $age = $_REQUEST['age'];
    $sports = $_REQUEST['sports'];
    $location = $_REQUEST['location'];

    // check to see if someone's hit generate already
    if( isset($name) == true && isset($age) == true && isset($sports) == true && isset($location) == true) {

    Header('Content-type: image/png');
    Header('Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0');
    Header('Expires: Thu, 19 Nov 1981 08:52:00 GMT');
    Header('Pragma: no-cache');

    // check the location
    if($location == "school") {
    $image = imagecreatefrompng('/full/path/to/images/school.png');
    }
    elseif($location == "work") {
    $image = imagecreatefrompng('/full/path/to/images/work.png');
    }
    elseif($location == "mall") {
    $image = imagecreatefrompng('/full/path/to/images/mall.png');
    }
    elseif($location == "library") {
    $image = imagecreatefrompng('/full/path/to/images/library.png');
    }
    elseif($location == "market") {
    $image = imagecreatefrompng('/full/path/to/images/market.png');
    }
    else { // we'll just set the default image to home
    $image = imagecreatefrompng('/full/path/to/images/home.png');
    }

    // text
    ImageTTFText($image, 8, 0, 10, 17, $black, '/fonts/VAG Round.ttf',
    "Name: " . $name . "\nAge: " . $age . "\nSports: " . $sports);

    // output and destroy
    imagepng($image);
    imagedestroy($image);

    }

    // if not, go ahead and show the form
    else {

    print ("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\"
    \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">
    <html xmlns=\"http://www.w3.org/1999/xhtml\" lang=\"en\" xml:lang=\"en\">
    <head>
    <title>Dynamic Signature Generator</title>
    <meta http-equiv=\"Content-type\" content=\"text/html; charset=ISO-8859-1\" />
    <style type=\"text/css\">
    body { font-family: tahoma, verdana, arial; }
    img { verical-align: middle; border-style: none; }
    </style>


    </head>

    <body>
    <h1>Dynamic Signature Generator</h1>

    <form method=\"post\" name=\"sig\" action=\"sig.php\">
    <small>
    Name: <input type=\"text\" name=\"name\" value=\"\" /><br />
    Age: <input type=\"text\" name=\"age\" value=\"\" /><br />
    Sports: <input type=\"text\" name=\"sports\" value=\"\" /><br />
    Location:
    <select name=\"location\">
    <option value=\"home\">Home</option>
    <option value=\"school\">School</option>
    <option value=\"work\">Work</option>
    <option value=\"library\">Library</option>
    <option value=\"mall\">Mall</option>
    <option value=\"market\">Market</option>
    </select><br />
    <br />
    <input type=\"submit\" value=\"Generate\" />
    </small>
    </form>

    </body>

    </html>");

    }

    ?>

    I want to make it, so that the location chosen, will make the image the background of the entire thing..

  14. Your syntax is incorrect. I highly suggest you do a little background reading on basic programming, specifically PHP, before going any further.

    The reason it's not working is because you're not doing any comparison on $location. Here's the complete code with a drop-down list to choose your location:

    <?php

    $name = $_REQUEST['name'];
    $age = $_REQUEST['age'];
    $sports = $_REQUEST['sports'];
    $location = $_REQUEST['location'];

    // check to see if someone's hit generate already
    if( isset($name) == true && isset($age) == true && isset($sports) == true && isset($location) == true ) {

    Header('Content-type: image/png');
    Header('Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0');
    Header('Expires: Thu, 19 Nov 1981 08:52:00 GMT');
    Header('Pragma: no-cache');

    // check the location
    if($location == "School") {
    $image = imagecreatefrompng('/full/path/to/images/school.png');
    }
    elseif($location == "Work") {
    $image = imagecreatefrompng('/full/path/to/images/work.png');
    }
    elseif($location == "Mall") {
    $image = imagecreatefrompng('/full/path/to/images/mall.png');
    }
    elseif($location == "Library") {
    $image = imagecreatefrompng('/full/path/to/images/library.png');
    }
    elseif($location == "Market") {
    $image = imagecreatefrompng('/full/path/to/images/market.png');
    }
    else { // we'll just set the default image to home
    $image = imagecreatefrompng('/full/path/to/images/home.png');
    }

    // set colours
    $white = imagecolorallocate($image, 255, 255, 255);
    $black = imagecolorallocate($image, 0, 0, 0);

    // text
    ImageTTFText($image, 8, 0, 10, 17, $black, '/full/path/to/verdana.ttf',
    "Name: " . $name . "\nAge: " . $age . "\nSports: " . $sports);

    // output and destroy
    imagepng($image);
    imagedestroy($image);

    }

    // if not, go ahead and show the form
    else {

    print ("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\"
    \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">
    <html xmlns=\"http://www.w3.org/1999/xhtml\" lang=\"en\" xml:lang=\"en\">
    <head>
    <title>Dynamic Signature Generator</title>
    <meta http-equiv=\"Content-type\" content=\"text/html; charset=ISO-8859-1\" />
    <style type=\"text/css\">
    body { font-family: tahoma, verdana, arial; }
    img { verical-align: middle; border-style: none; }
    </style>
    </head>

    <body>
    <h1>Dynamic Signature Generator</h1>

    <form method=\"post\" name=\"sig\" action=\"sig.php\">
    <small>
    Name: <input type=\"text\" name=\"name\" value=\"\" /><br />
    Age: <input type=\"text\" name=\"age\" value=\"\" /><br />
    Sports: <input type=\"text\" name=\"sports\" value=\"\" /><br />
    Location:
    <select name=\"location\">
    <option value=\"Home\">Home</option>
    <option value=\"School\">School</option>
    <option value=\"Work\">Work</option>
    <option value=\"Mall\">Mall</option>
    <option value=\"Library\">Library</option>
    <option value=\"Market\">Market</option>
    </select><br />
    <input type=\"submit\" value=\"Generate\" />
    </small>
    </form>

    </body>

    </html>");

    }

    ?>

    Also, be sure to use the full path to your image and font files. It'll save you time debugging if it ever causes problems otherwise.

    Oh, I had the drop already, I just didn't add it, because I didn't think that was the problem. But thanks for the help with the syntax, it's starting to get cleaer now.

    I have been using this site, to get the basics of HTML/CSS/PHP/ASP etc:

    http://www.w3schools.com/php/default.asp

    Though it doesn't explain the kinda things I need, either that or I'm probably not thinking in general terms with the exmaples their using. Do you have any suggestions as to where I could read up on PHP?

    EDIT:

    Ok, i think I messed everything up.

    I put in the corrections like you wrote it, but the images that are suppose to be called are suppose to be the background of the sig. So after I put the code in, I went to test it out, I filled in the form, and pressed generate, and what came up with just the name of link (as an image) which usually means somethings wrong with the code. After trying everything O could think of, to get it to work, I ended up just removed the "if..elseif...else" code, and replacing everything back to normal. And it still just shows the link as an image =/

    I keep going two steps up and 4 steps back =/

  15. What about arrays? or how to place the text where I want it? How would I incorporate that in with the code I have?

    I'm not quite sure what you want to know about arrays... But to answer your other questions...

    Read up on ImageTTFText here to manipulate the text: http://ca.php.net/manual/en/function.imagettftext.php

    Note that you can call ImageTTFText more than once to play in case you want to manipulate each line differently, for example:

    ImageTTFTextt($image, 8, 0, 10, 17, $black, '/path/to/font/file.ttf', "Name: " . $name);
    ImageTTFTextt($image, 8, 0, 20, 34, $black, '/path/to/font/file.ttf', "Age: " . $age);
    ImageTTFTextt($image, 10, 0, 30, 65, $black, '/path/to/font/file.ttf', "Sports: " . $sports);

    First off, this will not change the appearance of the first line. Secondly, it will shift the second line over further to the right by 10 pixels. Finally, the third line will be shifted downwards a bit more and will appear in size 10pt font instead of size 8pt.

    Oh, okay, thank you for that, now I have been been trying to get the (select) code to work with the .php, this is what im trying to do, could you point out what im doing wrong?

    $location = $_REQUEST['location'] {
    if('home') {
    $image = @imagecreatefrompng('images/home.png');
    }
    if('school') {
    $image = @imagecreatefrompng('images/school.png');
    }
    if('work') {
    $image = @imagecreatefrompng('images/work.png');
    }
    if('mall') {
    $image = @imagecreatefrompng('images/mall.png');
    }
    if('library') {
    $image = @imagecreatefrompng('images/library.png');
    }
    if('market') {
    $image = @imagecreatefrompng('images/market.png');
    }
    }

    // check to see if someone's hit generate already
    if( isset($name) == true && isset($age) == true && isset($sports) == true && isset($location) == true)

    ...skipping the stuff I haven't touched yet...

    // text
    ImageTTFText($image, 8, 0, 10, 17, $black, '/fonts/VAG Round.ttf',
    "Name: " . $name . "\nAge: " . $age . "\nSports: " . $sports . "\nLocation: " . $location);

    What I want to do, is for it to get the image of the selected location..

    Again, I want to thank you for helping me =D

  16. Okay good, because little knowledge me, already found a problem, lol =/

    When I try and test it out, I typed things in, and hit generate, and it takes me to a picture of a white square with a black border, but no text =/ I even put in a new text file, and made sure the access "link" to it, was right, and still nothing..

    EDIT: haha, stupid me, I spelled the folder wrong.

    Okay next question,

    Say I had a [select] code on the form, how would I make it so it would appear on the image? meaning how would i write the .php nvmd got that one.

    What about arrays? or how to place the text where I want it? How would I incorporate that in with the code I have?

  17. Hi, to make a long.. long story short.

    I found this thread:

    http://www.msfn.org/board/index.php?showtopic=47730

    While searching about how to make my own Dynamic Signature code.

    Now to the hard part, I'll try to explain it without sounding crazy.

    I would like to know how make it, so that my Dynamic sig code, would be created, when someone fills out a form.

    An example:

    Name: [bob]

    Age: [19]

    Activities: [sports]

    [Generate]

    Okay, above this is my crude form. I would like to know how to make it so that when a person fills out the form, and hits Generate, the information from that form, will be put into the dynamic sig code, so the person can save it, etc.. etc..

    I know how to make the form, I just need to know how to make the PHP/PNG codes so that when the form is filled out, everything works correctly.

    I am very desperate at this point in time, to get this code to work. I have been trying at it for a good 6 months now. I am not very well knowledged in PHP, and I know PHP can get very VERY extensive, but I want to do this, and feel like I have accomplished something. Lol, can you understand that?

    Well, there, I tried my best not to sound crazy.. I hope you can help me, if not, it's ok.

×
×
  • Create New...