Beanmen Posted August 22, 2014 Share Posted August 22, 2014 Hi there, As the question says i tried several things but i can't work it out and my knowledge about php isn't that well. <form> <div class="text-box"> <label> <input type="text" class="textbox" value="Your Name:" onfocus="this.value = '';" onblur="if (this.value == '') {this.value = 'Your Name:';}"> </label> <label> <input type="text" class="textbox" value="Your Email:" onfocus="this.value = '';" onblur="if (this.value == '') {this.value = 'Your Email:';}"> </label> <div class="clear"></div> </div> <textarea value="Your Message:" onfocus="this.value = '';" onblur="if (this.value == '') {this.value = 'Your Message:';}">Message</textarea> <input type="submit" value="Send Message"> </form> Quote Link to comment Share on other sites More sharing options...
CroNiX Posted August 22, 2014 Share Posted August 22, 2014 Not clear on what you mean. There isn't any php in that form. Quote Link to comment Share on other sites More sharing options...
Beanmen Posted August 22, 2014 Author Share Posted August 22, 2014 Not clear on what you mean. There isn't any php in that form. Sorry haha that is what i meant, i don't know how to build up the php part for the form Quote Link to comment Share on other sites More sharing options...
cyberRobot Posted August 22, 2014 Share Posted August 22, 2014 Perhaps you can start here: http://php.net/manual/en/tutorial.forms.php There also many tutorials online to get you started. https://www.google.com/search?q=php%20form Quote Link to comment Share on other sites More sharing options...
Beanmen Posted August 22, 2014 Author Share Posted August 22, 2014 Perhaps you can start here: http://php.net/manual/en/tutorial.forms.php There also many tutorials online to get you started. https://www.google.com/search?q=php%20form thankyou Quote Link to comment Share on other sites More sharing options...
Digitizer Posted August 24, 2014 Share Posted August 24, 2014 You might be imagining this part of PHP wrong, PHP is Pre HyperText Processor, means, anything to do with PHP on page, will be processed before displaying HTML to user. If you were to use PHP inside forms or let say, you wanted the form to be PHPized, There could be two ways, as in my humble opininon, <?php /* suppose we have some variables or data coming from PHP and we want to use them in HTML form - I am using hardcoding for simplicity and better understanding */ $username = "theUser"; $group = "admin"; if($group == 'admin'){$isAdmin = true;} else {$isAdmin = false;} /* One way is as follows, to use the HTML inside PHP ------------------------------------------------------------------------------ I want so set a condition that if username is declared and user group is admin, display the following form */ if($isAdmin){ echo(" <form name='myForm' method='post' action='" . $_SERVER['PHP_SELF'] . "'> <input type='text' name='username' value = '" . $username . "' /> <input type='submit' name='submitForm' value='Go' /> </form> "); } else { echo "You do not have permission to do blah blah"; } /* Note that we have been doing everyhting of this inside <?php ?> tag Now we will try to use the same form outside <?php tag */ ?> <!-- The Other way is outside php tag and using html straight Please not that how I am using <?php //code ?> tags inside the form to get data from PHP --> <?php if($isAdmin){ ?> <form name="myForm" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>"> <input type="text" name="username" value="<?php echo $username; ?>" /> <input type="submit" name="submitForm" value="Go" /> </form> <?php } else { ?> <span>You do not have permission to do blah blah</span> <?php } ?> I hope you will get it. Quote Link to comment Share on other sites More sharing options...
mogosselin Posted August 24, 2014 Share Posted August 24, 2014 @Beanmen : When you post code in the forum, you can use the 'code' button and paste your code in the popup that will appear, this way the code will have colour and will have a better format. That being said, you should tell us: The example you provided only has HTML, no PHP code. Do you have PHP installed on your computer? Or do you plan to code directly on a web server, for example by uploading PHP files with FTP? If you don't have PHP installed, you should check out XAMP (for Mac) or WAMP (for Windows), it will install PHP on your machine for you. Do you want to create a contact form that will be send by email? It looks like this from your field names. If that's what you want, you can check out my tutorial: http://www.mogosselin.com/simple-php-contact-form/ (shamelessplug) or check Google for 'php contact form', I'm sure there is a ton of those. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.