turkman Posted June 30, 2008 Share Posted June 30, 2008 Well i actually have two questions. 1) Last night i was trying to use a php script to generate a web form. i was using sprintf im sorry i don't have the code but it was late last night and i gave up and now im in work. Basically the web form displayed ok, but when i clicked the submit button, nothing happened even though id asked the form to open blah.php in the action part. I was wondering if this is a problem because i tried to make the form using php ? or if this is a normal problem, i dont have the code but it was basically <form action="blah.php method=GET> then i had two text boxes and a submit button 2)as opposed to getting a submit button to call a new page, can you get it to call a php function on the same page? Link to comment https://forums.phpfreaks.com/topic/112560-php-and-web-forms-question/ Share on other sites More sharing options...
MasterACE14 Posted June 30, 2008 Share Posted June 30, 2008 this: <form action="blah.php method=GET> needs to be this: <form action="blah.php" method="GET"> then on blah.php if you want to call a function you just setup blah.php like this: <?php // call whatever functions here echo "I just called the echo function"; ?> Regards ACE Link to comment https://forums.phpfreaks.com/topic/112560-php-and-web-forms-question/#findComment-578049 Share on other sites More sharing options...
Guest Posted June 30, 2008 Share Posted June 30, 2008 MasterACE14 got number 1 as for number 2 i think youd need ajax so the form could submit using javascript and not change the page. Link to comment https://forums.phpfreaks.com/topic/112560-php-and-web-forms-question/#findComment-578051 Share on other sites More sharing options...
MasterACE14 Posted June 30, 2008 Share Posted June 30, 2008 depends what he wants. If he wants the form to go to a new page. Then my way is all he needs, but if he wants to submit the info to the same page the form is on, he can do that with just PHP anyway. But if he wants it dynamic then he will need AJAX. Link to comment https://forums.phpfreaks.com/topic/112560-php-and-web-forms-question/#findComment-578055 Share on other sites More sharing options...
Guest Posted June 30, 2008 Share Posted June 30, 2008 Yea I know what your saying I was thinking ajax because as opposed to getting a submit button to call a new page I dont know though did we answer your question turkman ? Link to comment https://forums.phpfreaks.com/topic/112560-php-and-web-forms-question/#findComment-578058 Share on other sites More sharing options...
turkman Posted June 30, 2008 Author Share Posted June 30, 2008 Hey, thanks for the replies, in regards to the first one when i typed it out i didnt have a ending quote after the blah.php but i dont think i had the GET in quotes which may have caused the error? I assumed it was because i was building it with sprintf and adding the quotes like this \" Im not sure. Regarding the second question, i don't need ajax, i just need to post whats in the form into the database when they click submit, usually ive added a new file like postdata.php and called that, but its making a huge number of files and im starting to think its unnecessary. is there any reason i can't just call a function in the same page and get it to submit the data? How would that work <form action="enterdata()" > can someone show me how to make the submit button call a function to enter the data into the database. hope this is clearer Link to comment https://forums.phpfreaks.com/topic/112560-php-and-web-forms-question/#findComment-578105 Share on other sites More sharing options...
MasterACE14 Posted June 30, 2008 Share Posted June 30, 2008 <?php if(isset($_GET['name']) && strlen(trim(stripslashes($_GET['name']))) > 0) {) { // thanks to ken for the replacement for empty() mysql_query("") or die("Query could not execute!"); } else { ?> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="GET"> <input type="text" name="name"> <input type="submit" value="submit"> </form> <?php } ?> thats very basic. Regards ACE Link to comment https://forums.phpfreaks.com/topic/112560-php-and-web-forms-question/#findComment-578111 Share on other sites More sharing options...
turkman Posted June 30, 2008 Author Share Posted June 30, 2008 Thanks for the reply. i'll try the changes when i get home and if i still cant get the button to work then ill post the code. Link to comment https://forums.phpfreaks.com/topic/112560-php-and-web-forms-question/#findComment-578150 Share on other sites More sharing options...
MasterACE14 Posted June 30, 2008 Share Posted June 30, 2008 ok, good luck Link to comment https://forums.phpfreaks.com/topic/112560-php-and-web-forms-question/#findComment-578154 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.