PHP - Moved: Javascript Adding Inputs Blank All :s
This topic has been moved to JavaScript Help.
http://www.phpfreaks.com/forums/index.php?topic=313970.0 Similar TutorialsHello, I am very very new to PHP and have created a form that changes depending on a selection option. The website is here http://www.rmdesignstudio.com.au/wraptinprint/quotes.php and the PHP is all on the quotes.php page. The form sends to the email but when you fill in one form (example: Business Cards) the form sends, but along with all the entered fields the email also includes all the fields in all the hidden forms that werent filled in. I believe it is because they are drop down boxes and it is sending the first option in the list which happens to be "-----Please Select-----" Is there something I should be doing to my selection input field for this not to show up? Otherwise is there something I need to add to my PHP so it checks for the fields being filled in? I dont know how to add my code to this post, so if you could either show me or view my code via view source that would be awesome. This topic has been moved to Third Party PHP Scripts. http://www.phpfreaks.com/forums/index.php?topic=318598.0 This topic has been moved to Editor Help (Dreamweaver, Zend, etc). http://www.phpfreaks.com/forums/index.php?topic=349934.0 This topic has been moved to Third Party PHP Scripts. http://www.phpfreaks.com/forums/index.php?topic=355108.0 How is it possible, in PHP, to display an error message next to a form input text field if a user is attempting to submit a form with empty fields? Moreover, how is it possible to remove the same error message when the user fills in the input field with the required data and/or refreshes the page? I have 2 files that I am working with: application.php and process.php.
application.php mainly has the HTML of the form. I am very new to learning PHP (I started learning it last week) and I have been searching for hours for a clear answer. I have already tried different methods for generating the error message including: using empty(), !isset, $_POST["name"] = "", etc, and have tried using session_start();, $row, echo, print, and other variables to try and display error message on the page, and I have tried using unset();, and = null, to try and remove the error message once the input field has been filled but all to no avail. Either the method I try only half works, or nothing works, and I cannot pinpoint which is the part that is not working. I only have 2 files to work with, and as an example of what I want to do is:
1. If the first name field is empty when the user clicks submit, an error message should appear next to the input. Is this possible with PHP? This topic has been moved to JavaScript Help. http://www.phpfreaks.com/forums/index.php?topic=330084.0 This topic has been moved to Third Party PHP Scripts. http://www.phpfreaks.com/forums/index.php?topic=317600.0 This topic has been moved to JavaScript Help. http://www.phpfreaks.com/forums/index.php?topic=306905.0 This topic has been moved to PHP Applications. http://www.phpfreaks.com/forums/index.php?topic=354302.0 This topic has been moved to Third Party PHP Scripts. http://www.phpfreaks.com/forums/index.php?topic=358003.0 This topic has been moved to MySQL Help. http://www.phpfreaks.com/forums/index.php?topic=315503.0 This topic has teleported to Third Party PHP Scripts. Beam me up, Scotty. http://www.phpfreaks.com/forums/index.php?topic=343682.0 This topic has been moved to Other Libraries and Frameworks. http://www.phpfreaks.com/forums/index.php?topic=355225.0 This topic has been moved to HTML Help. http://www.phpfreaks.com/forums/index.php?topic=352099.0 This topic has been moved to MySQL Help. http://www.phpfreaks.com/forums/index.php?topic=313325.0 I just want some advice and need to know if I can do the following the script which displays partially like this Code: [Select] function getMainLogo() { global $dir, $site; $sFileName = getParam('sys_main_logo'); if(!file_exists($dir['mediaImages'] . $sFileName)) return ''; return '<a href="' . BX_DOL_URL_ROOT . '"><img src="' . $site['mediaImages'] . $sFileName . '" class="mainLogo" alt="logo" /></a>'; } function getPromoImagesArray() { global $dir; Can I add the javascript so its like this? Code: [Select] function getMainLogo() { global $dir, $site; echo ' < script type="text/javascript > banners = new Array(); banners[0] = "www.weareapackage.com,weareapackage.com/images/WePackageBanner.gif,Dating for Single Parents,468,60"; banners[1] = "www.friendsordating.com,www.friendsordating.com/images/bannersketch (2).png,Free Dating for Singles,468,60"; banners[2] = "www.lovelooker.com,parentmeets.com/images/LoveLooker.gif,Adult Dating,468,60"; rand = Math.floor(Math.random() * banners.length); b = banners[rand].split(","); url = b[0]; img = b[1]; des = b[2]; wid = b[3]; hei = b[4]; document.write('<a href="' + url + '" target="_blank"><img src="' + img + '" width="'+ wid +'" height="'+ hei +'" border="0" alt="' + des + '" /></a>'); < /script type="text/javascript > ;' } $sFileName = getParam('sys_main_logo'); if(!file_exists($dir['mediaImages'] . $sFileName)) return ''; return '<a href="' . BX_DOL_URL_ROOT . '"><img src="' . $site['mediaImages'] . $sFileName . '" class="mainLogo" alt="logo" /></a>'; } function getPromoImagesArray() { global $dir; Im not familiar with adding the javascript to the middle of the code, I am not asking for a debugger I am just asking for friendly advice, I am very new to this and dont completely understand, thank you. Hi, I have this PHP code which displays a form input, but I cannot work out how to add this javascript to the text field. PHP: <?php $data = '<div class="ui-widget infoBoxContainerSearch">' . ' <div class="ui-widget-contentSearch infoBoxContentsSearch" style="text-align: center;">' . ' <div style="text-align: center;">' . tep_draw_form('quick_find', tep_href_link(FILENAME_ADVANCED_SEARCH_RESULT, '', 'NONSSL', false), 'get') . '' . ' ' . tep_draw_input_field('keywords', '') . ' ' . tep_draw_hidden_field('search_in_description', '1') . tep_hide_session_id() //. tep_image_submit('search_icon.png', MODULE_BOXES_SEARCH_BOX_TITLE) . '</div>' . ' </form>' . ' </div>' . '</div>'; echo $data; ?> JavaScript: value="Search" onfocus="this.value==this.defaultValue?this.value='':null" onblur="this.value==''?this.value=this.defaultValue:null;" Could anyone point me in the right direction? Thanks Hi, I am using Mouseflow analytics in a phpbb forum. In my specific application, I need to add their application's javascript code inside php code. How do I properly add Javascript code inside a php code. Thanks This is how I would add it to an html file <script type="text/javascript"> var _mfq = _mfq || []; (function () { var mf = document.createElement("script"); mf.type = "text/javascript"; mf.async = true; mf.src = "//cdn.mouseflow.com/projects/b22343cd9-0049-4443-8326-954444462d6515.js"; document.getElementsByTagName("head")[0].appendChild(mf); })(); </script> Does anyone have any idea why my inputs shrink (to default height and weight) after i press submit button? I use css width and height for inputs. All other settings (border, background color etc.) remain like they should. For form submit i use PHP self function where i check if submit button has been pressed and then perform the form action. Thank you II have been told that I should sanitize my inputs, what does that mean? Isn't that what trim does? |