TechArena Community

TechArena Community (http://forums.techarena.in/)
-   Software Development (http://forums.techarena.in/software-development/)
-   -   How to reload form (http://forums.techarena.in/software-development/1026399.htm)

Dusto 25-08-2008 03:11 PM

How to reload form
 
Hi All
I am creating a simple web site which will display user ads, so I have some forms they submit, here is a snippet of the code:
Code:

<div class="createlisting">

<div class="clinput">
Ad Title... (up to 100 characters)<br>
<?php
print '<input type="text" name="item_title"';
print s_att("item_title","value",100);
if (isset($err["item_title_err"]))
{print ' class="err"> '.$err["item_title_err"];}
else
{print '>';}
?>
<br>
</div>

I need to get users to agree to my terms and conditions, so something like:

if //checkbox they can click to agree else // if unchecked, reload the same form...
Not sure how to do this, can anyome help?

Reegan 25-08-2008 03:14 PM

That is why people use form classes / functions/ whatever

Then you can do stuff like
Code:

$form->set('checkbox','mycheckbox','myvalue',ISSET);

if($form->validate()){

// form validates

} else {

$form->show();

}

Otherwise you have to cede like
Code:

if(!empty($_POST['myform'])){

array_push($aErrors,'mycheckbox');

}

// etc


if(sizeof($aErors)){

inlcude('form.php');

} else {

// form validates

}


form.php

<input type="checkbox" name="mycheckbox">
<?php if(isset($aErrors['mycheckbox'])){

echo 'Whoops';

}?>
etc


MindSpace 25-08-2008 03:17 PM

Quote:

Originally Posted by Reegan (Post 3939245)
That is why people use form classes / functions/ whatever

Then you can do stuff like
[code]$form->set('checkbox','mycheckbox','myvalue',ISSET);

So what's your favorite form class?

Reegan 25-08-2008 03:18 PM

Classes are irrelevant to this situation. In fact classes should never be used with PHP. They offer very few advantages and make code totally obscure. That is not welcome and should be avoided at all costs in any validation action.

If you need to use classes you should not be using a script language anyway.

MindSpace 25-08-2008 03:35 PM

Quote:

Originally Posted by Reegan (Post 3939249)
Classes are irrelevant to this situation. In fact classes should never be used with PHP. They offer very few advantages and make code totally obscure. That is not welcome and should be avoided at all costs in any validation action.

If you need to use classes you should not be using a script language anyway.

I dont agree. Classes are actually great. They make code much more reliable and maintainable.


All times are GMT +5.5. The time now is 02:54 PM.