amitojduggal Posted November 15, 2006 Share Posted November 15, 2006 Hello everyoneI 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 pageNot 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 likeecho "<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 errorplease help me make it workThanks!!Amitoj Link to comment https://forums.phpfreaks.com/topic/27345-help-regarding-forms/ Share on other sites More sharing options...
fert Posted November 15, 2006 Share Posted November 15, 2006 you need to escape the quotes like this:[code]echo "<form method=\"post\" action=\"some_page.php\">";[/code] Link to comment https://forums.phpfreaks.com/topic/27345-help-regarding-forms/#findComment-125020 Share on other sites More sharing options...
Cep Posted November 15, 2006 Share Posted November 15, 2006 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 okIf ($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 More sharing options...
amitojduggal Posted November 15, 2006 Author Share Posted November 15, 2006 Thanks very much sirfert and cepIt worked I didn't escaped " , thats why the error was thereWow guys u rockThanks again!!! Link to comment https://forums.phpfreaks.com/topic/27345-help-regarding-forms/#findComment-125025 Share on other sites More sharing options...
amitojduggal Posted November 15, 2006 Author Share Posted November 15, 2006 One more thing, if u can help meI want to store all values in database, and then make another page through which i can see them easilyCan u help me??or can give some good tutorial link??Can u please explain how??Amitoj Link to comment https://forums.phpfreaks.com/topic/27345-help-regarding-forms/#findComment-125026 Share on other sites More sharing options...
Cep Posted November 16, 2006 Share Posted November 16, 2006 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 tables2. A SELECT query to get back information from your database tables3. 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 More sharing options...
exploo Posted November 16, 2006 Share Posted November 16, 2006 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 More sharing options...
amitojduggal Posted November 16, 2006 Author Share Posted November 16, 2006 ya thats a better way since i don't have to escape " again and again it gets messy alot.Thanks anyways Link to comment https://forums.phpfreaks.com/topic/27345-help-regarding-forms/#findComment-125555 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.