Jump to content
xisto Community
Sign in to follow this  
iGuest

php easy?

Recommended Posts

hiEverybody seem to think that php is so easy that even firsttimers can easily work it out.I have plenty of html experience but know nothing about php so when i decided to try my hand on a simple form, i started looking around for tutorials. Trying to understand without knowing the lingo, gave me a monster headache so instead i downloaded some of the scripts and programs from hotscripts. Needless to say that none of them worked. In the end i 'borrowed' a script and tried to adapt it and finally after 3 days of trial and error i got it working. Hooray i'm a genius!!! :) Seriously --- it doesn't appear to be difficult, once you've got the gist of it, but guy's - cut the newbies a bit of slack. :P

Share this post


Link to post
Share on other sites

Hmm...working with PHP requiers at least some basic experience with programming, then it's really easy. But honestly, I wouldn't call HTML pages "programming", so...

Share this post


Link to post
Share on other sites

yes if you are experienced with a programming language then php is not that difficult. the basic idea is the same. but for more complex projects the things get out of hand (at least for me)...

Share this post


Link to post
Share on other sites

the best way to start php is probably not adjusting a script IMO - that misses out a stage. - the very first stage :) - here...

1) save all as anyfilename.php

2) printing basic html

<?print 'hello world';?>

open the file - it will show the words hello world with no formatting.

3) printing and setting variables

<?$hello = 'hello world';///setting variablesprint $hello;///printing variables ?>


4) if else with variables

<?$a = $_GET['a'];///setting variables  (3)if (isset($a)) {print '<a href="?a=0">Click here</a><br>';///printing html (2)print "a is set to:".$a;} else {print '<a href="?a=1">Click here</a><br>';///printing html (2)print "a is empty";}?>


then learn mysql commands and your sorted...

Share this post


Link to post
Share on other sites

All i wanted was a simple form (actually - what i really wanted was to know a bit about what all this php stuff was about) so i'm quite happy, - for now. :) But thanks for the code, i've tried it and you're right it probably is a better place to start, mind you if i hadn't tried my hand on the other script I would still be just as confused. :?

Share this post


Link to post
Share on other sites

PHP:hypertext Preprocessor is easy to learn and implement than the object based ASP and other scripts. Any one who come from C/C++ and perl background can easily go along with PHPs. And the easiest and most important part is its easy database connectivity. Even a toddler can connect to the back end data base.
Here is my homesite which in which I have used PHP to maintain my guestbook, feedbacks and sitestats...
http://forums.xisto.com/no_longer_exists/

enjoy surfing and be welll

Share this post


Link to post
Share on other sites

Hey any one interesed in PHP here goes the starting point

KNOW ABOUT VARIABLES

Variable are those entity which changes during the program execution. They contain informatin you need to place in required place. To create a variable in PHP is easy. Just plac $ sign before any word but the word should not start with numbers... but can follow any string including (_) underscore.

eg.

$name ="The DEVIL":

$_POST['username']="theDevil";

The scope of variable is upto the function or page in which the variable is defined

There are global variables also which are accesible throughtout the session of the site. Use global keyword before a varialble to make it global

eg

global $name;

global $address;

Share this post


Link to post
Share on other sites

All i wanted was a simple form (actually - what i really wanted was to know a bit about what all this php stuff was about) so i'm quite happy, - for now.  :)  

cool cool :P

for a form... adjusting my last script from above...


1) create the form html - save as form.php.

<?$form = <<<HTML<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><title>Form!</title><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"></head><body><form action="?a=1" method="post" name="" id="">  <table width="50%" border="0" align="center" cellpadding="4" cellspacing="0">    <tr>       <td width="22%">Subject</td>      <td width="78%"><input name="value" type="text" id="value"></td>    </tr>  </table></form></body></html><br>HTML;?>

then save the following as anythingyouwant.php .... load it...and should work as a simple form.
<?include 'form.php';///include the form - so that you can print it when you need to.$a = $_GET['a'];///setting variables  - has the script been submitted yet?if (isset($a)) {///the script has been submitted$value = $_POST['value'];///retrieve the posted data.print '<a href="/?">Click here</a><br>';///printing html - return to script not submittedprint "value is set to:".$value;} else {////form isnt submitted - so print it.print "a is empty<br>";print "therefore include the form<br><br>";///printing html (2)print $form;}?> 


should work... unless i missed off a ; or something silly :P

Share this post


Link to post
Share on other sites

welbis

 

Thanks again for your contribution. At least it makes me read it and think a bit about it. 8)

I'll try it as soon as i get time. Do I read it correctly if I see no 'required fields' check? :wink:

 

 

geancanach

 

im not a big fan of php

It may be so, but the time will come when plain html is no longer enough no matter how good you are.

Even today you will be hard pressed to find a website without some kind of

programming or scripting embedded in the code. Javascript is still the most

common, but the trend seems to go towards php. :?

 

 

many beginner level tutorials  

http://forums.xisto.com/no_longer_exists/  

 

some more advanced tutorials and examples  http://php.resourceindex.com/tips_and_tutorials/examples_and_tutorials/

There's no shortage of manuals and other help on the net.

One of my main problems here is, that english is not my native language, so

extensive and/or technical manuals of any description tend to put me off :roll:

Share this post


Link to post
Share on other sites

thedevil.I had a look at your website. It looks neat and tasteful, but do you really think it is wise with all that information about yourself. :?: :?: :?: It is an open invitation to all sorts of spammers and scammers and other scum. :evil:

Share this post


Link to post
Share on other sites

Do I read it correctly if I see no 'required fields' check?  :wink:

Yep :)

that form can be any html, so long as the method is post, then $_POST['variable'] will be the value entered in the form... i must confess im not sure which part of the html assigns that name, its either the id or the name - so i just set them both to be the same :P - though if you know you could let me know?

if you want to check the required fields, this would be the edited version.....

<?include 'form.php';///include the form - so that you can print it when you need to.$a = $_GET['a'];///setting variables  - has the script been submitted yet?if (isset($a)) {///the script has been submitted$value = $_POST['value'];///retrieve the posted data.if(isset($value)) {/////////FIELD SET?////////////print '<a href="/?">Click here</a><br>';///printing html - return to script not submittedprint "value is set to:".$value;} else {//////FEILD NOT SET - show form again, with message to fill it out///////print "The required fields are empty<br>";print "therefore include the form<br><br>";///printing html (2)print $form;}} else {////form isnt submitted - so print it.print "a is empty<br>";print "therefore include the form<br><br>";///printing html (2)print $form;}?>

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | 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.