darksniperx
Members-
Posts
113 -
Joined
-
Last visited
Never
Everything posted by darksniperx
-
I have feed.php, the include works , without problems <?php function showFeed() { $language = 'en'; include_once getcwd() .'/lang/Feed_' .$language. '.php'; I have feed_js_script.php, that contains js script that is being echoed into feed.php, since the script changes the names of few tags, I need it to have multilanguage support too. <?php function showFeedJS() { include_once 'forms.php'; $language = 'en'; include_once getcwd() .'/lang/Feed_'.$language.'.php'; as soon as i include language file into feed_js_script.php , then php ignores the include that I did for feed.php
-
could not use since i am not at www root. Works Great thx..
-
my ftp is down, I will try as soon as it comes back up. Thx for all your support. Thats why phpfreaks.com rocks!!!!
-
I head that php include and relative path are a pain, and that it sees "../" as "/", is there anyway to fix that. I am using php 4.x
-
code:inside Feed.php $language = 'en'; include_once '../lang/Feed_' .$language. '.php'; error: Warning: showfeed(../lang/Feed_en.php) [function.showfeed]: failed to open stream: No such file or directory in /home/frdowd3/public_html/alex/alpha/forms/Feed.php on line 5 Warning: showfeed() [function.include]: Failed opening '../lang/Feed_en.php' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/frdowd3/public_html/alex/alpha/forms/Feed.php on line 5 directory structure: alpha\ -forms\ -Feed.php -lang\ -Feed_en.php what can I do to fix the error, and I have checked all files are where they are suppose to be.
-
[SOLVED] php mulilanguage reference help
darksniperx replied to darksniperx's topic in PHP Coding Help
pohoje mnogo russko govorashih na forume. If I understand correctly then the code would look something like this-> <!--index.php?lang=en --> <?php $language = $_GET['lang']; include_once 'lang_' .$language. '.php'; ?> <html> <head></head> <body> <!-- top of the webpage header --> <?php echo $lang['header']; ?> <hr /> <form method='post'> <?php echo $lang['user']; ?><input type='text' name='user_id' /><br /> <?php echo $lang['pass']; ?><input type='password name='pass_id' /><br /> <input type='button' value='<?php echo $lang['submit_button']; ?>'/> </form> </body </html> <!-- lang_en.php --> <?php $lang['header']='Welcome to my site!'; $lang['user']='Username:'; $lang['pass']='Password:'; $lang['submit_button']='Submit'; ?> if I am correct then the code should look something like this? -
I have talked to few people and they said that php 4 has a function to handle multi language support. From what I heard you define a test file for each language and php grabs the text. I have try to search the web and this form and with no luck. Would anyone be able to point me to the right direction, or link to a tutorial. thx..
-
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...
-
<?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']); }
-
php echoes content in adress bar instead of html content?
darksniperx replied to darksniperx's topic in PHP Coding Help
is there anything I can do, so when I submit, it would load a blank page with submit results instead of redisplaying the whole form? -
php echoes content in adress bar instead of html content?
darksniperx replied to darksniperx's topic in PHP Coding Help
what can I do so it would not echo the message in action attribute -
php echoes content in adress bar instead of html content?
darksniperx replied to darksniperx's topic in PHP Coding Help
form generated <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" > <head> <meta http-equiv="Content-Script-Type" content="text/javascript; charset=UTF-8;" /> <title>Index Page!</title> <script type='text/javascript'> function loader() { showAdvanced(this.form); setPublishedDate(); publishedDate(); } var showForm = "none"; function showAdvanced(current_form) { if(showForm == "none") { document.getElementById("advancedTitle_table").style.display = "none"; document.getElementById("id_table").style.display = "none"; document.getElementById("publish_table").style.display = "none"; document.getElementById("optionalData_table").style.display = "none"; document.getElementById("optionalMetadata_table").style.display = "none"; document.getElementById("attributes_table").style.display = "none"; document.getElementById("showHide").value = "Show Advanced Options"; showForm = ""; } else { document.getElementById("advancedTitle_table").style.display = "block"; document.getElementById("id_table").style.display = "block"; document.getElementById("publish_table").style.display = "block"; document.getElementById("optionalData_table").style.display = "block"; document.getElementById("optionalMetadata_table").style.display = "block"; document.getElementById("attributes_table").style.display = "block"; document.getElementById("showHide").value = 'Hide Advanced Options'; showForm = "none"; } } //function to set published date function setPublishedDate() { document.getElementById("pub_year_id").value = '2007'; document.getElementById("pub_month_id").value = '10'; document.getElementById("pub_day_id").value = '24'; document.getElementById("pub_hour_id").value = '13'; document.getElementById("pub_min_id").value = '20'; document.getElementById("pub_sec_id").value = '08'; document.getElementById("pub_zone_id").value = '-04:00'; } // These functions control the xml:base and xml:lang optional attributes function xmlBase_cascade_display( current_form ) { if ( current_form.entry_base_checkbox.checked == false ) { document.getElementById("xmlBase_cascade_option").style.display = "none"; current_form.e_base.value = ""; current_form.commonBASE_checkbox.checked = false; } if ( current_form.entry_base_checkbox.checked == true ) { document.getElementById("xmlBase_cascade_option").style.display = "block"; } }//end of xmlBase_cascade_display() //sets base to default settings function setBASEDefault(value) { if(value == 'set') { document.getElementById("entry_base_id").value = document.getElementById("e_base_id").value; document.getElementById("id_base_id").value = document.getElementById("e_base_id").value; } else { document.getElementById("entry_base_id").value = ''; document.getElementById("id_base_id").value = ''; } } //sets base to rest of the form function setBASERest(value) { if(value == 'set') { document.getElementById("title_base_id").value = document.getElementById("e_base_id").value; document.getElementById("updated_base_id").value = document.getElementById("e_base_id").value; document.getElementById("content_base_id").value = document.getElementById("e_base_id").value; document.getElementById("published_base_id").value = document.getElementById("e_base_id").value; document.getElementById("rights_base_id").value = document.getElementById("e_base_id").value; document.getElementById("summary_base_id").value = document.getElementById("e_base_id").value; document.getElementById("l_base_id").value = document.getElementById("e_base_id").value; } else { document.getElementById("title_base_id").value = ''; document.getElementById("updated_base_id").value = ''; document.getElementById("content_base_id").value = ''; document.getElementById("published_base_id").value = ''; document.getElementById("rights_base_id").value = ''; document.getElementById("summary_base_id").value = ''; document.getElementById("l_base_id").value = ''; } } function setLANGDefault(value) { if(value == 'set') { document.getElementById("entry_lang_id").value = document.getElementById("e_lang_id").value; document.getElementById("id_lang_id").value = document.getElementById("e_lang_id").value; } else { document.getElementById("entry_lang_id").value = ''; document.getElementById("id_lang_id").value = ''; } } function setLANGRest(value) { if(value == 'set') { document.getElementById("title_lang_id").value = document.getElementById("e_lang_id").value; document.getElementById("updated_lang_id").value = document.getElementById("e_lang_id").value; document.getElementById("content_lang_id").value = document.getElementById("e_lang_id").value; document.getElementById("published_lang_id").value = document.getElementById("e_lang_id").value; document.getElementById("rights_lang_id").value = document.getElementById("e_lang_id").value; document.getElementById("summary_lang_id").value = document.getElementById("e_lang_id").value; document.getElementById("l_lang_id").value = document.getElementById("e_lang_id").value; } else { document.getElementById("title_lang_id").value = ''; document.getElementById("updated_lang_id").value = ''; document.getElementById("content_lang_id").value = ''; document.getElementById("published_lang_id").value = ''; document.getElementById("rights_lang_id").value = ''; document.getElementById("summary_lang_id").value = ''; document.getElementById("l_lang_id").value = ''; } } function eBase_change( current_form ) { current_form.entry_base_checkbox.checked = true; document.getElementById("xmlBase_cascade_option").style.display = "block"; if ( current_form.e_base.value == '' ) { current_form.entry_base_checkbox.checked = false; current_form.commonBASE_checkbox.checked = false; document.getElementById("xmlBase_cascade_option").style.display = "none"; } }//end of eBase_change() function xmlLang_cascade_display( current_form ) { if ( current_form.entry_lang_checkbox.checked === false ) { document.getElementById("xmlLang_cascade_option").style.display = "none"; current_form.e_lang.options[0].selected = true; current_form.commonLANG_checkbox.checked = false; } if ( current_form.entry_lang_checkbox.checked === true ) { document.getElementById("xmlLang_cascade_option").style.display = "block"; } }//end of xmlLang_cascade_display() function eLang_change( current_form ) { current_form.entry_lang_checkbox.checked = true; document.getElementById("xmlLang_cascade_option").style.display = "block"; if ( current_form.e_lang.options[current_form.e_lang.selectedIndex].value == "none" ) { current_form.entry_lang_checkbox.checked = false; document.getElementById("xmlLang_cascade_option").style.display = "none"; current_form.commonLANG_checkbox.checked = false; } }//end of eLang_change() // This function controls the display of the table for entering Published data function published_table_display( current_form ) { if ( current_form.useUpdated.checked === true ) { document.getElementById("published_table").style.display = "none"; } if ( current_form.useUpdated.checked === false ) { document.getElementById("published_table").style.display = "block"; } }//end of published_table_display() function rights_table_display( current_form ) { if ( current_form.rights.checked === false ) { document.getElementById("rights_table").style.display = "none"; } if ( current_form.rights.checked === true ) { document.getElementById("rights_table").style.display = "block"; } }//end of rights_table_display() function summary_table_display( current_form ) { if ( current_form.summary.checked === false ) { document.getElementById("summary_table").style.display = "none"; } if ( current_form.summary.checked === true ) { document.getElementById("summary_table").style.display = "block"; } }//end of summary_table_display() function publishedDate() { if(document.getElementById("date_type_off").checked == true) { document.getElementById("pub_year_id").setAttribute("readonly", "true"); document.getElementById("pub_month_id").setAttribute("readonly", "true"); document.getElementById("pub_day_id").setAttribute("readonly", "true"); document.getElementById("pub_hour_id").setAttribute("readonly", "true"); document.getElementById("pub_min_id").setAttribute("readonly", "true"); document.getElementById("pub_sec_id").setAttribute("readonly", "true"); document.getElementById("pub_zone_id").setAttribute("readonly", "true"); setPublishedDate(); } else { document.getElementById("pub_year_id").readOnly=''; document.getElementById("pub_month_id").readOnly=''; document.getElementById("pub_day_id").readOnly=''; document.getElementById("pub_hour_id").readOnly=''; document.getElementById("pub_min_id").readOnly=''; document.getElementById("pub_sec_id").readOnly=''; document.getElementById("pub_zone_id").readOnly=''; } } function validator() { if(document.getElementById("entry_base_checkbox_id").checked == true) { setBASEDefault('set'); } if(document.getElementById("entry_base_checkbox_id").checked == false) { setBASEDefault('none'); } if(document.getElementById("commonBASE_checkbox_id").checked == true) { setBASERest('set'); } if (document.getElementById("commonBASE_checkbox_id").checked == false) { setBASERest('none'); } if(document.getElementById("entry_lang_checkbox_id").checked == true) { setLANGDefault('set'); } if(document.getElementById("entry_lang_checkbox_id").checked == false) { setLANGDefault('none'); } if(document.getElementById("commonLANG_checkbox_id").checked == true) { setLANGRest('set'); } if(document.getElementById("commonLANG_checkbox_id").checked == false) { setLANGRest('none'); } } </script> </head> <body onload='loader();'> <form method="post" action="" onsubmit="validator()"> <h1>Welcome to Fusion Project!</h1> <h3>You are about to create a news entry.</h3> <h3>Remember that <font color='red'>*</font> means that the field is required and if you are an <u>advanced user</u><br/> you can press <u>advanced button</u> to add a variety of options and other usefull information.</h3> <hr /> <p><font color='red'>*</font><strong>Story Title <font size="-1">(Please enter a descriptive title for the story you're linking to.)</font></strong></p> <p> <input type='text' name='title_text' size="100" /> </p> <p><font color='red'>*</font><strong>Story Description <font size="-1">(Write your own description of the news story.)</font></strong></p> <p> <textarea cols="75" rows="5" name="content_text" ></textarea> </p> <font color='red'><strong>*</strong></font><strong>Story Link <font size="-1">(Link that points to the source of the story.)</font></strong> <p> <input type='text' name='l_href' size="100" /> </p> <strong><font color="#FF0000">*</font>Categories:</strong> <p> <label><input type='checkbox' name='cat_id[]' value='1'/>Food</label><label><input type='checkbox' name='cat_id[]' value='2'/>Gas</label><label><input type='checkbox' name='cat_id[]' value='3'/>Religion</label><label><input type='checkbox' name='cat_id[]' value='4'/>Chips</label><label><input type='checkbox' name='cat_id[]' value='5'/>Drinks</label></p> <p><strong>Authors and contributors.</strong></p> <table width="438" border="0"> <tr> <td width="210" colspan="2" ><font color="#FF0000">*</font>Author</td> <td width="210" colspan="2">Contributor</td> </tr> <tr> <td valign="top" > Name:<br/> E-mail:<br/> Website:<br/> </td> <td valign="top"> <input type="text" name="author_name" /><br/> <input type="text" name="author_email" /><br/> <input type="text" name="author_website" /><br/> </td> <td valign="top"> Name:<br/> E-mail:<br/> Website:<br/> </td> <td valign="top"> <input type="text" name="contributor_name" /><br/> <input type="text" name="contributor_email" /><br/> <input type="text" name="contributor_website" /><br/> </td> </tr> </table> <table id="advancedTitle_table" > <tr> <td> <hr /> <h2>The following was activated by <u>advanced button</u> to add a variety of options and other usefull information.</h2> <hr /> </td> </tr> </table> <table id="id_table"> <tr> <td><p><strong>Id for your entry:</strong></p> ID URI: <input type='text' name='id_uri' id='id_uri_id' size="55" value="URN:UUID:7B311F3F-444B-486F-9BC4-3DF17BA4E1EE" /> </td></tr> </table> <table id="publish_table"> <tr> <td><p><strong>Published Date </strong></p> Published date: <input type="text" id="pub_year_id" name="published_yyyy" size="4" />- <input type='text' id="pub_month_id" name='published_mo' size="2" />- <input type='text' id="pub_day_id" name='published_dd' size="2" /> T <input type='text' id="pub_hour_id" name='published_hh' size="2"/>: <input type='text' id="pub_min_id" name='published_mi' size="2"/>: <input type='text' id="pub_sec_id" name='published_ss' size="2"/>. <input type='text' id="pub_zone_id" name='published_zone' size="6"/> <br /> <input type="radio" id="date_type_off" name="date_type" value="current_date" checked="checked" onclick="publishedDate();"/> Use current date and time! (upon submit the date and time will regen) <input type="radio" id="date_type_on" name="date_type" value="custom_date" onclick="publishedDate();" /> Use custom date and time! </td></tr> </table> <table id="optionalData_table"> <tr> <td><p><strong>Optional Data</strong></p> <input name="rights" id="rights" type="checkbox" onclick="rights_table_display( this.form );" /> <u>Include Rights</u> <table id="rights_table" style=" margin-left: 50px; display:none;"> <tr> <td colspan="2"> <h4>Copyright Text:</h4> <input type='text' name='rights_text' /> </td> </tr> <tr> <td><b>Text Type</b></td> </tr> <tr> <td> <input type="radio" name="rights_type" value="Text" checked="checked"/> Text<br/> <input type="radio" name="rights_type" value="Html" /> Html<br/> <input type="radio" name="rights_type" value="XHtml"/> XHtml<br/> </td> </tr> </table> <br/> <input name="summary" id="summary" type="checkbox" onclick="summary_table_display( this.form );" /> <u>Include Summary</u> <table id="summary_table" style="margin-left: 50px; display:none;"> <tr> <td colspan="2"><h4><font color='red'>*</font>Summary </h4> <textarea cols="75" rows="5" name="summary_text" ></textarea> </td> </tr> <tr> <td><b>Text Type</b></td> </tr> <tr> <td> <input type="radio" name="summary_type" value="Text" checked="checked"/> Text<br/> <input type="radio" name="summary_type" value="Html" /> Html<br/> <input type="radio" name="summary_type" value="XHtml"/> XHtml<br/> </td> </tr> </table> </td></tr> </table> <table id="optionalMetadata_table"> <tr> <td><p><strong>Optional Metadata</strong></p> <p> <input name="entry_base_checkbox" id="entry_base_checkbox_id" type="checkbox" onclick="xmlBase_cascade_display( this.form );"/> xml:base attribute for this AED: <input type='text' id="e_base_id" name='e_base' onkeyup="eBase_change(this.form);" value='' /> </p> <p id="xmlBase_cascade_option" style="margin-left: 50px; display:none"> <input name="commonBASE_checkbox" id="commonBASE_checkbox_id" type="checkbox" /> Check the box if you want this attribute to cascade throughout the rest of the document. </p> <p> <input name="entry_lang_checkbox" id="entry_lang_checkbox_id" type="checkbox" onclick="xmlLang_cascade_display( this.form );" /> xml:lang attribute for this AED: <select name='e_lang' id="e_lang_id" onchange="eLang_change( this.form );"> <option value ='none' selected="selected" ></option> <option value ='EN'>English</option> <option value ='FR'>French</option> <option value ='RU'>Russian</option> </select> </p> <p id="xmlLang_cascade_option" style="margin-left: 50px; display:none"> <input name="commonLANG_checkbox" id="commonLANG_checkbox_id" type="checkbox" /> Check the box if you want this attribute to cascade throughout the rest of the document. </p> </td></tr> </table> <table id="attributes_table"> <tr> <td><p><strong>Attributes data types</strong></p> <table> <tr> <th>Title Type</th> <th>Story Type</th> </tr> <tr> <td> <input type="radio" name="title_type" value="Text" checked="checked"/> Text<br/> <input type="radio" name="title_type" value="Html" /> Html<br/> <input type="radio" name="title_type" value="XHtml"/> XHtml<br/> </td> <td> <input type="radio" name="content_type" value="Text" checked="checked"/> Text<br/> <input type="radio" name="content_type" value="Html" /> Html<br/> <input type="radio" name="content_type" value="XHtml"/> XHtml<br/> </td> </tr> </table> </td></tr> </table> <table id="hidden_table" style="display:none"> <tr> <td> <input type="hidden" id="entry_base_id" name="entry_base" value="" /> <input type="hidden" id="id_base_id" name="id_base" value="" /> <input type="hidden" id="title_base_id" name="title_base" value="" /> <input type="hidden" id="updated_base_id" name="updated_base" value="" /> <input type="hidden" id="content_base_id" name="content_base" value="" /> <input type="hidden" id="published_base_id" name="published_base" value="" /> <input type="hidden" id="rights_base_id" name="rights_base" value="" /> <input type="hidden" id="summary_base_id" name="summary_base" value="" /> <input type="hidden" id="l_base_id" name="l_base" value="" /> <input type="hidden" id="entry_lang_id" name="entry_lang" value="" /> <input type="hidden" id="id_lang_id" name="id_lang" value="" /> <input type="hidden" id="title_lang_id" name="title_lang" value="" /> <input type="hidden" id="updated_lang_id" name="updated_lang" value="" /> <input type="hidden" id="content_lang_id" name="content_lang" value="" /> <input type="hidden" id="published_lang_id" name="published_lang" value="" /> <input type="hidden" id="rights_lang_id" name="rights_lang" value="" /> <input type="hidden" id="summary_lang_id" name="summary_lang" value="" /> <input type="hidden" id="l_lang_id" name="l_lang" value="" /> </td> </tr> </table> <hr /> <h2>Ready to submit?</h2> <p>Congratulations! You are now ready to submit the data needed to create a new Atom Entry Document. Clicking on the Submit button will first activate a validation function, which will make sure all required info is present prior to submitting it to the database. Also you can click advanced options button to perform advanced operations!</p> <p> <input type='reset' value='Reset' /> | <input name='formEntry_submit' type='submit' value='Submit' /> | <input type="button" onclick="showAdvanced(this.form);" id="showHide" value="Show Advanced Options" /> </p> </form> </body> </html> after first submit, it changes the data in form action tag. -
php echoes content in adress bar instead of html content?
darksniperx replied to darksniperx's topic in PHP Coding Help
index.php <?php include_once 'forms.php'; $webForm = "Entry"; //specify which form you want to work with $form = new forms; // create an instance of selected class $form->setFormData($webForm); // populate class variables selected form ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" > <head> <meta http-equiv="Content-Script-Type" content="text/javascript; charset=UTF-8;" /> <title>Index Page!</title> <?php $form->outputHeaderData(); // echo any content in the head section ?> </head> <body <?php $form->ouputBodyAttributeData(); // echo any content that is suppose to be in body tag ?>> <?php $form->outputForm(); // echo any content in the body section ?> </body> </html> Entry.php <?php function showEntry() { $form = new forms; // create an instance of selected class ?> <form method="post" action="<?php $form->formSwitch(); ?>" onsubmit="validator()"> <h1>Welcome to Fusion Project!</h1> <h3>You are about to create a news entry.</h3> <h3>Remember that <font color='red'>*</font> means that the field is required and if you are an <u>advanced user</u><br/> you can press <u>advanced button</u> to add a variety of options and other usefull information.</h3> <hr /> <p><font color='red'>*</font><strong>Story Title <font size="-1">(Please enter a descriptive title for the story you're linking to.)</font></strong></p> <p> <input type='text' name='title_text' size="100" /> ... </p> 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']); } fusion.php <?php class fusion { VAR $CON,$SQL; VAR $database_location = 'localhost'; VAR $database = ****; VAR $db_user = *****; VAR $db_pass = *****; //adding data to entry function addToEntry( $entry_id,$e_base,$e_lang,$id_base,$id_lang,$id_uri, $title_base,$title_lang,$title_type,$title_text, $updated_base,$updated_lang,$updated_date, $CONtent_lang,$CONtent_base,$CONtent_type,$CONtent_text, $published_base,$published_lang,$published_date, $rights_base,$rights_lang,$rights_type,$rights_text, $summary_base,$summary_lang,$summary_type,$summary_text,$x_element, $content_src,$source_base,$source_lang,$source_metadata ) { $SQL = "INSERT INTO entry ( entry_id,e_base,e_lang,id_base,id_lang,id_uri, title_base,title_lang,title_type,title_text, updated_base,updated_lang,updated_date, content_lang,content_base,content_type,content_text, published_base,published_lang,published_date, rights_base,rights_lang,rights_type,rights_text, summary_base,summary_lang,summary_type,summary_text,x_elements, content_src,source_base,source_lang,source_metadata ) VALUES ( 'entry_id','$e_base','$e_lang','$id_base','$id_lang','$id_uri', '$title_base','$title_lang','$title_type','$title_text', '$updated_base','$updated_lang','$updated_date', '$CONtent_lang','$CONtent_base','$CONtent_type','$CONtent_text', '$published_base','$published_lang','$published_date', '$rights_base','$rights_lang','$rights_type','$rights_text', '$summary_base','$summary_lang','$summary_type','$summary_text','$x_element', '$content_src','$source_base','$source_lang','$source_metadata' )"; if (!mysql_query($SQL,$this->$CON)) { die('Error: ' . mysql_error()); } echo "1 record added to <b>Entry</b><br/>"; }//end of addToentry(); *** forms.php and fusion.php are class, Entry.php echoes html content, index.php places html content in correct places. -
I have a form witch bunch of data that is was being submitted, that form passes $_POST data to a class called form which orgenizes the data then calles different methods from class fusion which then puts the data in the database and echoes during successfull submit "1 row was added to table form", but instead of echo that message on the body of the form, it echoes in the adress bar when I try to submit the form a second time which results in this: http://test.org/alex/test/1%20record%20added%20to%20%3Cb%3EEntry%3C/b%3E%3Cbr/%3E1%20record%20added%3Cbr/%3E1%20record%20added%3Cbr/%3E anyway to fix this?
-
[SOLVED] $_POST not recongnized anymore???
darksniperx replied to darksniperx's topic in PHP Coding Help
you have created a link to a class that accepts submitted forms ex: $form = new form; that class has a function that processes the form ex: formSubmit(); I have used a default constructor and if else method to find which form was beins submitted. I have taken out if else statement from default constructor and changed <form> tag to this ex: <form action="<?php $form->formSubmit(); ?>" method="post"> -
I have html form from time to time I access methods from class forms since it contains all of the function are needed to work with forms. in the form it self I request 2 different functions from class form, the thing is when I press submit button, the form submits it self the ammount of times as the function that request data from forms.php class. html doc $forms-> new form; <form method="post" action="" onsubmit="validator()"> A<input type='text' value="<?php $form->getA(); ?>"/> B<input type='text' value="<?php $form->getB(); ?>"/> <input name='formEntry_submit' type='submit' value='Submit' /> | </form>
-
[SOLVED] $_POST not recongnized anymore???
darksniperx replied to darksniperx's topic in PHP Coding Help
I have figured out the issue. -
[SOLVED] $_POST not recongnized anymore???
darksniperx replied to darksniperx's topic in PHP Coding Help
** I wonder should I create php file that workes between html form, and form class? -
[SOLVED] $_POST not recongnized anymore???
darksniperx replied to darksniperx's topic in PHP Coding Help
<?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() { print_r($_POST); print_r($GLOBALS); } I get no ouput when I press submit button before I submit I get Array ( ) nothing Array ( ) nothing // the code being in the same file that echoes form content when I put print global onsubmit, I get this Array ( ) Array ( [CONSOLE] => /dev/console [sELINUX_INIT] => YES [TERM] => linux [iNIT_VERSION] => sysvinit-2.85 [PATH] => /bin:/usr/bin:/sbin:/usr/sbin:/usr/local/bin:/usr/local/sbin [runlevel] => 3 [RUNLEVEL] => 3 [PWD] => / [noexec32] => off [LANG] => en_US.UTF-8 [previous] => N [PREVLEVEL] => N [pax_softmode] => 1 [sHLVL] => 3 [HOME] => / [RESTARTSRV] => 1 [_] => /usr/local/apache/bin/httpd [DOCUMENT_ROOT] => /home/frdowd3/public_html [HTTP_ACCEPT] => */* [HTTP_ACCEPT_ENCODING] => gzip, deflate [HTTP_ACCEPT_LANGUAGE] => en-ca [HTTP_CONNECTION] => Keep-Alive [HTTP_HOST] => adventus-test.org [HTTP_UA_CPU] => x86 [HTTP_USER_AGENT] => Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.1.4322; .NET CLR 2.0.50727; InfoPath.1; .NET CLR 3.0.04506.30) [REMOTE_ADDR] => 216.252.78.240 [REMOTE_PORT] => 3056 [sCRIPT_FILENAME] => /home/frdowd3/public_html/alex/test/index.php [sERVER_ADDR] => 67.43.10.51 [sERVER_ADMIN] => webmaster@adventus-test.org [sERVER_NAME] => www.adventus-test.org [sERVER_PORT] => 80 [sERVER_SIGNATURE] => -
at first I had a php class that contained a function to echo a form and a function to submit it to db <form method="post" action="<?php print $_SELF; ?>" onsubmit="validator()"> my class was getting too bulky so I put the form in a separate php file which echoes the content, so I have changed the form header to this. <form method="post" action="forms.php" onsubmit="validator()"> here is my forms class <?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; //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(); } } ... } I used bunch of if else statements to find which form is being submitted so I would load an appropriate function, but now when I submit the form, forms.php does nothing, $_POST values are not being passed????
-
nice it works now. I should have studied more about include tag, only if I knew. include_once() should be used in cases where the same file might be included and evaluated more than once during a particular execution of a script, and you want to be sure that it is included exactly once to avoid problems with function redefinitions, variable value reassignments, etc.
-
I found the cause of the problem. now what to do to fix it. here is my index page <?php include ("forms.php"); $webForm = "Entry"; //specify which form you want to work with $form = new forms; // create an instance of selected class $form->setFormData($webForm); // populate class variables selected form ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" > <head> <meta http-equiv="Content-Script-Type" content="text/javascript; charset=UTF-8;" /> <title>Index Page!</title> <?php $form->outputHeaderData(); // echo any content in the head section ?> </head> <body <?php $form->ouputBodyAttributeData(); // echo any content that is suppose to be in body tag ?>> <?php $form->outputForm(); // echo any content in the body section ?> </body> </html> forms.php includes the requested form contained in a different php file and then echoes it with <?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 'fusion.php'; $this->script = new fusion; //when form is being submitted, the following verifyies which form then loads appropriate methods. if($_POST['form_feed_submit']) { $this->formFeed_submit(); } } //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->script->dbConnect(); $this->script->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->script->closeDbConnection(); } the php file of the content that is being submitted. <?php function showEntry() { ?> <form method="post" action="<?php print $_SELF; ?>" onsubmit="validator()"> <h1>Welcome to Fusion Project!</h1> <h3>You are about to create a news entry.</h3> <h3>Remember that <font color='red'>*</font> means that the field is required and if you are an <u>advanced user</u><br/> you can press <u>advanced button</u> to add a variety of options and other usefull information.</h3> <hr /> <p><font color='red'>*</font><strong>Story Title <font size="-1">(Please enter a descriptive title for the story you're linking to.)</font></strong></p> <p> <input type='text' name='title_text' size="100" /> </p> <p><font color='red'>*</font><strong>Story Description <font size="-1">(Write your own description of the news story.)</font></strong></p> <p> <textarea cols="75" rows="5" name="content_text" ></textarea> </p> <font color='red'><strong>*</strong></font><strong>Story Link <font size="-1">(Link that points to the source of the story.)</font></strong> <p> <input type='text' name='l_href' size="100" /> </p> <strong><font color="#FF0000">*</font>Categories:</strong> <p> <?php $newForm = new forms; //*** this line creates problem $form->printCategoryBoxes();//print checkboxes ?> when I call $newForm = new forms; in php html file I get Fatal error: Cannot redeclare class fusion in /home/public_html/alex/test/fusion.php on line 3 fusion class <?php class fusion { VAR $CON,$SQL; VAR $database_location = 'localhost'; ... dont know what to do.
-
I havent done any changes to my php class files, I was working on tidying up my html form code, then when I test my website out, I get Fatal error: Cannot instantiate non-existent class:fusion ... line 15 <?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() { $this->script = new fusion; ... the thing is that the code worked, did not do any changes to it "I think". What can I look for to find the cause of the problem. My php is 4.3.9. thx.