darksniperx Posted October 25, 2007 Share Posted October 25, 2007 <?php function showEntry() { $form = new forms; // create an instance of selected class ?> <form method="post" action="<?php $form->formSwitch(); ?>" onsubmit="validator()"> ... after I press submit, php changes the form tag to: <form method="post" action="1 record added to Entry 1 record added" onsubmit="validator()"> forms.php only echoes the status of submission, if the form was submitted or not, but instead of echo in the the body of html content it echoes inside action="" attribute. Also is there anyway to change so that I could use forms.php instead of $form->formSwitch(); in action attribute, because forms.php is a class it doesnt let just pass $_POST variables. Also right now my index.php that contains a form, upon submission reloads the form, is there anyway I can change it so it would load a blank page that would display the status of submission? here is the code in forms.php <?php class forms { var $script; //temporary variables to use with forms var $js_script; var $css_script; var $body_onload_content; var $body_content; function forms() { include_once 'fusion.php'; $this->fusion = new fusion; } function formSwitch() { if($_POST) { //when form is being submitted, the following verifyies which form then loads appropriate methods. if($_POST['form_feed_submit']) { $this->formFeed_submit(); } else if($_POST['formEntry_submit']) { $this->formEntry_submit(); } else if($_POST['form_person_submit']) { $this->formPerson_submit(); } else if($_POST['form_category_submit']) { $this->formCategory_submit(); } else if($_POST['form_link_submit']) { $this->formLink_submit(); } else if($_POST['form_feed_edit']) { $this->formFeed_update_submit(); } else { echo "nothing"; } } } //sets variable data that will be later used in the forms function setFormData($formName) { include $formName . '.php'; include '../scripts/' . $formName . '_js_script.php'; $this->js_script = 'show' . $formName . 'JS'; $this->body_onload_content = "onload='loader();'"; $this->body_content = 'show'.$formName; } //outputs data that is suppose to be in header tag function outputHeaderData() { echo "<script type='text/javascript'>"; echo "\n"; $x = $this->js_script; $x(); echo "</script>"; echo "\n"; } //output data inside body tag function ouputBodyAttributeData() { echo $this->body_onload_content; } //writes form data to html file for the requested form function outputForm() { $x = $this->body_content; $x(); } //prints the data from category table with check boxes function printCategoryBoxes() { $this->fusion->dbConnect(); $this->fusion->selectDb(); $category = mysql_query("SELECT * FROM category") OR die(mysql_error()); while($cat = mysql_fetch_array($category)) { echo "<label><input type='checkbox' name='cat_id[]' value='".$cat['cat_id']."'/>".$cat['c_label']."</label>"; } $this->fusion->closeDbConnection(); } //return uuid to the user function getUUID() { echo 'URN:UUID:' . strtoupper($this->fusion->getUUID()); } function formEntry_submit() { $this->fusion->dbConnect(); $this->fusion->selectDb(); $search = mysql_query("SELECT * FROM entry ORDER BY entry_id DESC"); //get the next free entry spot $last = mysql_fetch_array($search); $newEntryNumber = $last['entry_id']+1; //set date to proper format $date = $_POST['published_yyyy']."-".$_POST['published_mo']."-".$_POST['published_dd']."T". $_POST['published_hh'].":".$_POST['published_mi'].":".$_POST['published_ss']."".$_POST['published_zone']; //insert into table entry $this->fusion->addToEntry($newEntryNumber,$_POST['e_base'],$_POST['e_lang'], $_POST['id_base'],$_POST['id_lang'],$_POST['id_uri'], $_POST['title_base'],$_POST['title_lang'],$_POST['title_type'],$_POST['title_text'], $_POST['updated_base'],$_POST['updated_lang'],$_POST['updated_date'], $_POST['content_lang'],$_POST['content_base'],$_POST['content_type'],$_POST['content_text'], $_POST['published_base'],$_POST['published_lang'],$date, $_POST['rights_base'],$_POST['rights_lang'],$_POST['rights_type'],$_POST['rights_text'], $_POST['summary_base'],$_POST['summary_lang'],$_POST['summary_type'],$_POST['summary_text'],"", $_POST['content_src'],$_POST['source_base'],$_POST['source_lang'],$_POST['source_metadata']); } Link to comment https://forums.phpfreaks.com/topic/74736-solved-php-changed-form-action-content-when-it-is-not-suppose-to/ Share on other sites More sharing options...
MadTechie Posted October 25, 2007 Share Posted October 25, 2007 because one of the function form->formSwitch(); is echoing that.. why not just put the File path in? or do <?php function showEntry() { $form = new forms; // create an instance of selected class $form->formSwitch(); ?> <form method="post" onsubmit="validator()"> ... Link to comment https://forums.phpfreaks.com/topic/74736-solved-php-changed-form-action-content-when-it-is-not-suppose-to/#findComment-377797 Share on other sites More sharing options...
darksniperx Posted October 25, 2007 Author Share Posted October 25, 2007 I tryed to file path <form method="post" action="forms.php" onsubmit="validator()"> I get a blank page when I submit a form. forms.php a class and doesnt want to accept $_POST variables, unless I do $form->formSwitch(); if I knew how to go around it. Also does php has a function to stop what ever it is doing including stopping the page load, etc... Link to comment https://forums.phpfreaks.com/topic/74736-solved-php-changed-form-action-content-when-it-is-not-suppose-to/#findComment-377829 Share on other sites More sharing options...
emehrkay Posted October 25, 2007 Share Posted October 25, 2007 I think you are going about this the wrong way. the action attribute basically tells your scrpt where to send the data to. You need a post/get processing page and in that page you call the $form->formSwitch(); method to handle the post results. Understand? //forms.php class forms{ formSwitch(){ //do stuff with post vars } } $form = new forms(); $form->formSwitch(); //end forms.php Link to comment https://forums.phpfreaks.com/topic/74736-solved-php-changed-form-action-content-when-it-is-not-suppose-to/#findComment-377838 Share on other sites More sharing options...
darksniperx Posted October 26, 2007 Author Share Posted October 26, 2007 before <form> I have added if($_POST) { $form->formSwitch(); } and that has fixed all of my problems, thx.. Link to comment https://forums.phpfreaks.com/topic/74736-solved-php-changed-form-action-content-when-it-is-not-suppose-to/#findComment-378374 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.