Jump to content

help regarding forms!!!


amitojduggal

Recommended Posts

Hello everyone

I need to make form for my college work,
I know basic coding in php,
I did most of the things on the forms, except for validation.
I made a check whether any field has been left, if left it gives use to give message to hit back button. Else it echos the values so user can check.

Now i also made a button on the page that says submit after form validation, like the action page
Not the front page but the one that checks for valid entries.
Now i want to insert a ok button only if all entries are correct, is there a way to make button visible only when all entries are correct.

for example can i do like
echo "<form id="form1" name="form1" method="post" action="Thanks.php">
    <label></label>

   
    <div align="center">
      <input type="submit" name="Submit" value="Submit" />
    </div>
    <label>
   
    <div align="center"></div>
    </label>
  </form>";

It gives error
please help me make it work
Thanks!!
Amitoj
Link to comment
https://forums.phpfreaks.com/topic/27345-help-regarding-forms/
Share on other sites

You can either code php to display it has part of a variable or you can use client side script. To use php to display you would have to post the information first and then show the result. Something as simple as,
[code=php:0]
// Where you perform your checks for the data I have just said $data is ok
If ($data=="ok") {
$string = "<input name='ok' type='button' value='ok' />";
} else {
$string = "";
}

echo $string;
[/code]
Link to comment
https://forums.phpfreaks.com/topic/27345-help-regarding-forms/#findComment-125021
Share on other sites

The best places are the PHP manual on the main page www.phpfreaks.com this will give you all the code you need to perform this task, then it is just a matter of selecting an appropriate database, I would strongly suggest MySQL and as it happens we have a MySQL manual on the main page too ;)

As a hint, You will need to look at,

1. An INSERT query to place data in your database tables
2. A SELECT query to get back information from your database tables
3. A Loop control in your php code, such as WHILE or FOR to process each record in your tables when querying.
Link to comment
https://forums.phpfreaks.com/topic/27345-help-regarding-forms/#findComment-125463
Share on other sites

Also I wouldn't run all that code through echo..

This is how i would do it..

[code]
<form id="form1" name="form1" method="post" action="Thanks.php">
    <label></label>
 
    <div align="center">

      <?php if ($data=="ok") { ?>

          <input type="submit" name="Submit" value="Submit" />

      <?php } ?>

    </div>

    <label>
      <div align="center"></div>
    </label>
</form>
[/code]

When you do it this way, there is no need to escape the code. :)
Link to comment
https://forums.phpfreaks.com/topic/27345-help-regarding-forms/#findComment-125553
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.