Jump to content

Ninjakreborn

Members
  • Posts

    3,922
  • Joined

  • Last visited

Everything posted by Ninjakreborn

  1. How do I access strictly to a form field. I am trying to do something with javascript and php, I have a function created in javascript, that I am trying to secure, then I am going to use it with php to validate, what do I do to access a form field. Right now I have a function with onsubmit() and I called it, but I am not accessing the form fields right I tried multiple ways, because I also need to use this to create some classes in php, I tried for instance my firstname field I tried test form is the name of my form by they way document.testform.firstname I tried document.testform.['firstname'] document.testform.["firstname"] I even tried window.document.testform.firstname window.document.testform.['firstname'] and window.document.testform.["firstname"] nothing here gives me access to that form field. How do I correctly gain access to this,
  2. add " at the end of onclick="whatever"
  3. It's not that, I was wanting to know everything about php, when I see someone who knows php, they look at any script 20 minutes later have a fix. That is the point I am trying to get too, Same with javascript, then I need to do a little tidying with my css. and learn photoshop and graphic design.
  4. thanks I appreciate it, but how is reading a book going to help when everything is online,when I am reading a book I can't work from the book but I will give this a try if it might help then it's worth a try.
  5. ok I have done a few things new to it, I moved it from the external file to the same page, I suppose I have to learn how to do it on that page, before I can run it from an external file. Now I have done some modifications, found some errors, fixed a few things as I learned, but it still doesn't seem to work, here is all the code on the same page. I tried onSubmit="" like I was showed, but it didn't work it's actually onsubmit="" without the capital S, it turned up error on w3schools validator. So here is the new code. [code] <!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"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>php test page</title> <script language="javascript" type="text/javascript"> function checkform() {     if (document.formtest.firstname.text.firstname == ""){ alert('Please enter a first name!'); return false; } else if (document.formtest.text.lastname == "") { alert('Please enter a last name!'); return false; }     return true; } </script> </head> <body> Please fill in the following form and submit the information to me:<br  /> <form name="formtest" action="formprocessor.php" method="post" onsubmit="return checkform()"> First Name:<input name="firstname" type="text" maxlength="30" /><br /> Last Name:<input name="lastname" type="text" maxlength="30" /><br /> Age:<input name="age" type="text" maxlength="3" /><br /> Please enter desired Username:<input name="username" type="text" maxlength="35" /><br /> Please verify Username:<input name="verifyusername" type="text" maxlength="35" /><br /> Please enter desired password:<input name="password" type="password" maxlength="25" /><br /> Please verify your password:<input name="verifypassword" type="password" maxlength="25" /><br /> Now for the section to tell me a little bit about yourself.<br /> Please enter information about your personal life below:<br /> <input name="personallife" type="text" /><br /> Please enter all the programming languages you currently know:<br /> <input name="languages" type="text" /><br /> Please enter all your past experiences below:<br /> <input name="experiences" type="text" /><br /> Please check all that apply:<br /> I am:<br /> Perfect:<input name="iam[]" type="checkbox" value="perfect" /><br /> Obedient:<input name="iam[]" type="checkbox" value="obedient" /><br /> Incoherent:<input name="iam[]" type="checkbox" value="incoherent" /><br /> Drunk:<input name="iam[]" type="checkbox" value="drunk" /><br /> Unfocused:<input name="iam[]" type="checkbox" value="unfocused" /><br /> Desired:<input name="iam[]" type="checkbox" value="unfocused" /><br /> Unrelenting:<input name="iam[]" type="checkbox" value="unrelenting" /><br /> Full of Shit:<input name="iam[]" type="checkbox" value="fullofshit" /><br /> Uncircumsized:<input name="iam[]" type="checkbox" value="uncircumsized" /><br /> How would you say the following please pick only one:<br /> Thank you:<input name="choice" type="radio" checked="checked" value="thankyou" /><br /> Go To Hell:<input name="choice" type="radio" value="gotohell" /><br /> What are you doing:<input name="choice" type="radio" value="whatareyoudoing" /><br /> Now please pick out of the following, which ones apply to you:<br /> Fat:<input name="decision[]" type="checkbox" value="fat" /><br /> Skinny:<input name="decision[]" type="checkbox" value="skinny" /><br /> Tall:<input name="decision[]" type="checkbox" value="tall" /><br /> Short:<input name="decision[]" type="checkbox" value="short" /><br /> Man:<input name="decision[]" type="checkbox" value="man" /><br /> Woman:<input name="decision[]" type="checkbox" value="woman" /><br /> <input name="submit" type="submit" value="submit me now" /> <input name="reset" type="reset" value="reset this and die" /> </form> </body> </html> [/code] and it's still not working.
  6. I am I already know Xhtml, css, and "VERY LITTLE" javascript. Now a bit of php. I am wanting to build my site in xhtml, style it in css, put in some javascript, for basic validation, and preload images. Then I am wanting, just for knowledge, to have a form, that sends information to a database, to make sure I Have the basics of databasing, before I start to take on projects.
  7. thanks it not for my site, well it is, but I am also trying to start a career as a professional web designer, coder programmer. and I am just struggling with php and javascript, I haven't even started on sql yet.
  8. what's wrong with this. Form below [code] <!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"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>php test page</title> <script src="freelancebusinessman.js"></script> </head> <body> Please fill in the following form and submit the information to me:<br  /> <form name="formtest" action="formprocessor.php" method="post"> First Name:<input name="firstname" type="text" maxlength="30" /><br /> Last Name:<input name="lastname" type="text" maxlength="30" /><br /> Age:<input name="age" type="text" maxlength="3" /><br /> Please enter desired Username:<input name="username" type="text" maxlength="35" /><br /> Please verify Username:<input name="verifyusername" type="text" maxlength="35" /><br /> Please enter desired password:<input name="password" type="password" maxlength="25" /><br /> Please verify your password:<input name="verifypassword" type="password" maxlength="25" /><br /> Now for the section to tell me a little bit about yourself.<br /> Please enter information about your personal life below:<br /> <input name="personallife" type="text" /><br /> Please enter all the programming languages you currently know:<br /> <input name="languages" type="text" /><br /> Please enter all your past experiences below:<br /> <input name="experiences" type="text" /><br /> Please check all that apply:<br /> I am:<br /> Perfect:<input name="iam[]" type="checkbox" value="perfect" /><br /> Obedient:<input name="iam[]" type="checkbox" value="obedient" /><br /> Incoherent:<input name="iam[]" type="checkbox" value="incoherent" /><br /> Drunk:<input name="iam[]" type="checkbox" value="drunk" /><br /> Unfocused:<input name="iam[]" type="checkbox" value="unfocused" /><br /> Desired:<input name="iam[]" type="checkbox" value="unfocused" /><br /> Unrelenting:<input name="iam[]" type="checkbox" value="unrelenting" /><br /> Full of Shit:<input name="iam[]" type="checkbox" value="fullofshit" /><br /> Uncircumsized:<input name="iam[]" type="checkbox" value="uncircumsized" /><br /> How would you say the following please pick only one:<br /> Thank you:<input name="choice" type="radio" checked="checked" value="thankyou" /><br /> Go To Hell:<input name="choice" type="radio" value="gotohell" /><br /> What are you doing:<input name="choice" type="radio" value="whatareyoudoing" /><br /> Now please pick out of the following, which ones apply to you:<br /> Fat:<input name="decision[]" type="checkbox" value="fat" /><br /> Skinny:<input name="decision[]" type="checkbox" value="skinny" /><br /> Tall:<input name="decision[]" type="checkbox" value="tall" /><br /> Short:<input name="decision[]" type="checkbox" value="short" /><br /> Man:<input name="decision[]" type="checkbox" value="man" /><br /> Woman:<input name="decision[]" type="checkbox" value="woman" /><br /> <input name="submit" type="submit" value="submit me now" onsubmit="checkform()" /> <input name="reset" type="reset" value="reset this and die" /> </form> </body> </html> [/code] below is external javascript [code] function checkform() { if (document.formtest.firstname == ") { alert('Please enter a value for the First Name'); } else if (document.formtest.lastname == ") { alert('Please enter a value for the Last Name'); } return true; } [/code] and the problem is, it's doing nothing at all, nothing onsubmit, I know that hte onsubmit is there, but I also tried doing onsubmit="samething" at the <form> tag, and it didn't work either.[b]Problem solved/.[/b]
  9. I was asking for some advice, on moving foward with pulling this together, like what kind of programs to work on first, or should I continue trying to master javascript validation, should I server side validate on the same page or on teh same page the email is processing.
  10. I need some advice, I would really appreciate some help. I have come a long ways but now I am trying to put my stuff together, I got to where I could email form information. I just need to start validating with javascript and php. I need to figure out what I am going to do from here. How do I learn to code on my own, how do I learn to bring all this stuff together, php and javascript, I want to learn how to get all this stuff to come together to use with various tips, I have a good site I am using, but I still don't know where to go from here, so many questions, so little answers, and so much studying, yes I have been physically practicing with and fighting with this stuff as I go along.
  11. [code] <!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"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>php test page</title> </head> <body> Please fill in the following form and submit the information to me:<br  /> <form name="formtest" action="formprocessor.php" method="post"> First Name:<input name="firstname" type="text" maxlength="30" /><br /> Last Name:<input name="lastname" type="text" maxlength="30" /><br /> Age:<input name="age" type="text" maxlength="3" /><br /> Please enter desired Username:<input name="username" type="text" maxlength="35" /><br /> Please verify Username:<input name="verifyusername" type="text" maxlength="35" /><br /> Please enter desired password:<input name="password" type="password" maxlength="25" /><br /> Please verify your password:<input name="verifypassword" type="password" maxlength="25" /><br /> Now for the section to tell me a little bit about yourself.<br /> Please enter information about your personal life below:<br /> <input name="personallife" type="text" /><br /> Please enter all the programming languages you currently know:<br /> <input name="languages" type="text" /><br /> Please enter all your past experiences below:<br /> <input name="experiences" type="text" /><br /> Please check all that apply:<br /> I am:<br /> Perfect:<input name="iam[]" type="checkbox" value="perfect" /><br /> Obedient:<input name="iam[]" type="checkbox" value="obedient" /><br /> Incoherent:<input name="iam[]" type="checkbox" value="incoherent" /><br /> Drunk:<input name="iam[]" type="checkbox" value="drunk" /><br /> Unfocused:<input name="iam[]" type="checkbox" value="unfocused" /><br /> Desired:<input name="iam[]" type="checkbox" value="unfocused" /><br /> Unrelenting:<input name="iam[]" type="checkbox" value="unrelenting" /><br /> Full of crap:<input name="iam[]" type="checkbox" value="fullofcrap" /><br /> Uncircumsized:<input name="iam[]" type="checkbox" value="uncircumsized" /><br /> How would you say the following please pick only one:<br /> Thank you:<input name="choice" type="radio" checked="checked" value="thankyou" /><br /> Go To heck:<input name="choice" type="radio" value="gotoheck" /><br /> What are you doing:<input name="choice" type="radio" value="whatareyoudoing" /><br /> Now please pick out of the following, which ones apply to you:<br /> Fat:<input name="decision[]" type="checkbox" value="fat" /><br /> Skinny:<input name="decision[]" type="checkbox" value="skinny" /><br /> Tall:<input name="decision[]" type="checkbox" value="tall" /><br /> Short:<input name="decision[]" type="checkbox" value="short" /><br /> Man:<input name="decision[]" type="checkbox" value="man" /><br /> Woman:<input name="decision[]" type="checkbox" value="woman" /><br /> <input name="submit" type="submit" value="submit me now" /> <input name="reset" type="reset" value="reset this and die" /> </form> </body> </html> [/code] form above processor below I finally got those arrays to work right. [code] <!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"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>form processor</title> </head> <body> <?php $to = "businessman332211@hotmail.com"; $subject = "Freelance businessman test"; $firstname = $_POST['firstname']; $lastname = $_POST['lastname']; $age = $_POST['age']; $username = $_POST['username']; $verifyusername = $_POST['verifyusername']; $password = $_POST['password']; $verifypassword = $_POST['verifypassword']; $personallife = $_POST['personallife']; $languages = $_POST['languages']; $experiences = $_POST['experiences']; $choice = $_POST['choice']; $message = " First Name: $firstname Last Name: $lastname Age: $age User Name: $username Verify Username:$verifyusername Password: $password verifypassword: $verifypassword Personal Life: $personallife Languages: $languages Experiences: $experiences choice: $choice I Am: "; $message .= implode(', ', $_POST['iam']) . "\n" . 'Decision: '; $message .= implode(', ', $_POST['decision']); mail($to, $subject, $message); if (mail($to, $subject, $message)){ print "The email has been sent"; } else { print "The email has not been sent"; } ?> </body> </html> [/code] [b]Some of these had dirty languages so I edited them.[/b]
  12. i'll keep those in mind thanks.
  13. I know a lot more baout php now I have a specific question. I am trying to create my own function to handle arrays coming from form fields. Where I can just call the function and have it print the info, this may or may not work any ideas.
  14. I have learnt alot, I now know there is not just one set way to do everything, so I have been fighting with code trying to figure out ways to do things on my own, and things are coming together, I am having one problem here. I have a difficulty with any email script I create that gatheres form information, whenever I submit the form it emails it to me twice. Actually I ahve 2 questions. 1. Why does it email itself to me twice for each time I hit submit, is it somethign wrong with my script, or is there anyway to stop that. I know anything is possible with php but this is somethign I Don't know how to start with, I just began. 2. Why does it come into junk mail, at first it was, I set it to not junk in hotmail, and it worked, but if I ever send an email through php it is going to send it to junk mail, is there a way to change this at all, it will make it hard if I am every setting up email systems for people, or setting up something for, mailing lists, that is going to cause one major problem.
  15. is there any easier way to force checked boxes into an array and filter them into the message. Because someone came up with the perfect solution, but there is no way I can remember that and apply it to every situation. Age: $age\n"; foreach ($_POST['choices'] as $choices) $message .= "Choices: $choices\n"; $message .= "Location: $location that was cut directly into my code, which it worked, very miraculously it worked, I was very happy about that, but is there a way that I can rememebr, so when I make them again, I will nkow how to, whatever the situation when working with check boxes in a form.
  16. ok I finally made headway, can someone please explain this, I had a problem, someone here fixed my script, perfectly, I got into line feeds, I tried them on all the lines because of this. [a href=\"http://us3.php.net/manual/en/function.mail.php\" target=\"_blank\"]http://us3.php.net/manual/en/function.mail.php[/a] it said all lines under message should have a line feed at the end of each line when I did this it made the output in the email look extremly retarded, so what I did was I removed them and it went back to normal, I understand a little why the line feed worked like that now, ubt I don't understand why in the manual it says to insert a line feed after each one.
  17. as I said whether you try it or not is up to you, go to the element where you are specifying the text, position it manually with the positions I gave you, and just move each one over it takes 5 minutes for each one, to get it looking right, if you need me to do it I guess I can, but I don't like working for free. just input the positions where they need to be, visually adjust it as you go, until it is positioned to perfection. Then you will have them where you want them.
  18. ok thanks, that means I can or can not use the /n depending on whether I wanted to or not, so when I am processing information or somethign I can use /n, but when I am using php to output something a person can see, I should use <br /> thanks.
  19. I know everything is busy, I know theres not a lot of time left for people to answer questions, i just want to askthis final one for the day. In the other post I was asking questions, I set an array with checkboxes, or whatever it's called, then I called the array couldn't get it to work, someone modified my code [code] <?php $firstname = $_POST['firstname']; $lastname = $_POST['lastname']; $age = $_POST['age']; $location = $_POST['location']; $favorites = $_POST['favorites']; $username = $_POST['username']; $verifyusername = $_POST['verifyusername']; $password = $_POST['password']; $verifypassword = $_POST['verifypassword']; $to = "businessman332211@hotmail.com"; $subject = "freelance businessman!"; $body = " First Name: $firstname Last Name: $lastname Age: $age\n"; foreach ($_POST['choices'] as $choices)      $body .= "Choices: $choices\n"; $body .= "Location: $location Favorites: $favorites Username: $username Verify Username: $verifyusername Password: $password Verify Password: $verifypassword "; ?> [/code] I have to know some things can someone break down the whole section [code] Age: $age\n"; foreach ($_POST['choices'] as $choices)      $body .= "Choices: $choices\n"; $body .= "Location: $location [/code] I know what a foreach statement is. I am confused as to a few things here. 1. The \n I heard was a line feed, when I originally started with php I used this and got errors, replaced it always with <br /> after that and it worked fine. When he gave me this code, I took out the \n and put <br /> and it didn't work, i tried \n and it did and my jaw hit the floor. What is this, how does it work, and like this person here, when I do learn when to use \n, and when do I learn not too. For instance I don't think this could have been done without the \n. 2. Then he put a $body, in the middle of mybody I tried taking it out but it messed it up, why does he have that there, that is my variable named $body, he called it and said [code] $body .= Choices: $choices\n [/code] and then did that with location, why did he use the same variable that it was inside of what did $body = whatever do in those 2 places to fix my script. I don't understand this. 3. and last I see he used .= in 2 places on the script. I don't understand this, I searched all over, and searched the operators .= doesn't exist, yet it still worked, I know I am missing something I just need help figuring out what, I only ask questions on this forum, after running through dozens of tutorials and trying things out for myself for awhile, I dissected this entire code, it does not work at all unless all the elements he put in there are exactly the way he put them on, this confuses me as to all thes eelements to this script section are vital yet I understand very little ot it. Thanks for the help Side question-isn't as important but I was wondering when I set up that array it comes up when the thing is checked, then in the email it has the value name, is there anyway to have it say the sentence I have before the value. By the way the website if you are wondering where the form is, it's at www.freelancebusinessman.com/test.php it's only a test, while I lerarn all this stuff and to style the form. Thanks and the first 3 questions are critical, thanks again.
  20. wait answer htis question please, I really got confused when that worked. I saw about the /n when I was studying but was told it was for command line I figured I would never need it so I used <br /> instead this whole time, I tried your way, then with <br /> and your way worked, what happened please explain this too me, that code Iput it in like you said, and it came back, it had the values of what I had assigned on there, the only other thing I don't get is why it didn't print out the full message on there, but either way atleast it returned it to me, please explain what that /n is I know it's line feed but where does its usage come in at. [b]EDIT-one more question[/b] also what was the $body that you put int here, I tried modifying it again and taking those out, can someone break this section down for me to help me understand, it would be great for me since I am about to move into more advanced stuff/.
  21. I actually I decided to run a validation on the form, I had action set twice, typo, and had checked=check instead of checked=checked, so it works now, now I am starting to play with setting those checked fields into an array and passing it to the message. also, I would debug but I figured out the problem. with that ok here is what I tried, with various other attempts but it doesn't seem to work. [code] <?php foreach ($_POST['choices'] as $choices) $firstname = $_POST['firstname']; $lastname = $_POST['lastname']; $age = $_POST['age']; $location = $_POST['location']; $favorites = $_POST['favorites']; $username = $_POST['username']; $verifyusername = $_POST['verifyusername']; $password = $_POST['password']; $verifypassword = $_POST['verifypassword']; $to = "businessman332211@hotmail.com"; $subject = "freelance businessman!"; $body = " First Name: $firstname Last Name: $lastname Age: $age Choices: $choices Location: $location Favorites: $favorites Username: $username Verify Username: $verifyusername Password: $password Verify Password: $verifypassword "; mail($to, $subject, $body); if (mail($to, $subject, $body)) { print "The email was sent successfully"; } else { print "The email did not send successfully"; } ?> [/code] heres the form code [code] <form name="testform" action="formprocessor.php" method="post"> First Name:<input name="firstname" type="text" maxlength="20" /><br /> Last Name:<input name="lastname" type="text" maxlength="20" /><br /> Age:<input name="age" type="text" maxlength="3" /><br /> How you located this Website:<br /> <select name="location"> <option>Search Engine</option> <option>Browsing other</option> <option>freelance businessman</option> <option>You don't want to specify</option> </select> <br /> Pick one of the following:<br /> Video Games:<input name="favorites" type="radio" value="video games" checked="checked"/><br /> Tv:<input name="favorites" type="radio" value="tv" /><br /> Nothing:<input name="favorites" type="radio" value="nothing" /><br /> Please check all that apply:<br /> I am comfortable with my surroundings:<input name="choices[]" type="checkbox" value="I am comfortable with my surroundings" /><br /> I am angered by my surroundings:<input name="choices[]" type="checkbox" value="I am angered by my surroundings" /> <br /> I am bothered by my surroundings:<input name="choices[]" type="checkbox" value="I am bothered by my surroundings" /> <br /> I am worthless when people are around:<input name="choices[]" type="checkbox" value="I am worthless when people are around" /> <br /> I am unserious when people are around:<input name="choices[]" type="checkbox" value="I am unserious when people are around" /> <br /> Please choose a proper username:<input name="username" type="text" maxlength="30" /><br /> Please verify your username:<input name="verifyusername" type="text" maxlength="30" /><br /> Please add in your password:<input name="password" type="password" maxlength="25" /><br /> Please verify your password:<input name="verifypassword" type="password" maxlength="25" /><br /> <input name="submit" type="submit" value="submit" /> <input name="reset" type="reset" value="reset" /> Thank you for taking the time to fill out this form, if everything works correctly you will recieve a confirmation stating that it was completed successfully. </form> [/code] what I am trying to figure out is how to get that checkbox fields into an array and put them into an email that I have there to send to me, then after I get the basics I will know how I also tried setting the array manually on that page like array($whatever, $whatever, ) and setting it like that, i also tried setting it manually with the keys as well and then passing it into the text, but nothing has worked so far.
  22. I have still been fighting with it trying different ways, trying ways I see in tutorials, but still can't get it to work.
  23. I ran into another problem, I cut off the globals, I rewrite my entire script, first I tried setting the $_POST['username']; I tried setting those straight into the subject it didn't work so I tried registering all the variables like this. [code] <?php $to = "businessman332211@hotmail.com"; $subject = "freelance businessman!"; $firstname = $_POST['firstname']; $lastname = $_POST['lastname']; $age = $_POST['age']; $location = $_POST['location']; $favorites = $_POST['favorites']; $location = $_POST['location']; $username = $_POST['username']; $verifyusername = $_POST['verifyusername']; $password = $_POST['password']; $verifypassword = $_POST['verifypassword']; $body = " First Name: $firstname Last Name: $lastname Age: $age Location: $location Favorites: $favorites Username: $username Verify Username: $verifyusername Password: $password Verify Password: $verifypassword"; mail($to, $subject, $body); if (mail($to, $subject, $body)) { print "The email was sent successfully"; } else { print "The email did not send successfully"; } ?> [/code] What is happening is it is sending an email properly, but nothing is coming up where the variables are supposed to be, what could be wrong, I registered the variables to specific names, and called hte variables where I needed them at, and it didn't work.
  24. ok finally something that really helped, I was worried about the register globals, and now I am for sure, I will figure out how and turn that off, then I will change that information and get it to work and ask a few more questions, I still need to figure out how to string that as a array so I can let the email send me the informaiton
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.