
lbh2011
Members-
Posts
55 -
Joined
-
Last visited
Everything posted by lbh2011
-
I found the solution to my issue here: http://www.phpbb.com/community/viewtopic.php?f=46&t=2125887 Thanks for the suggestions Josh
-
Thanks for the reply. There are about 10 elements so the foreach approach seems the best option. How would I go about doing that?
-
Hi, I currently have the following code in my form processing script: $string_exp = "/^[A-Za-z .'-]+$/"; $error_missing = 'This field is required'; if(!preg_match($string_exp,$Name)) { $errors[] = $error_missing; } if(!preg_match($string_exp_number,$Phone)) { $errors[] = $error_missing; } if(is_array($errors)) { echo 'Your message could not be sent due to the following errors:'; while (list($key,$value) = each($errors)) { echo '<span class="error">'.$value.'</span><br />'; } If the user enters no data into the required fields, the script prevents the form from being submitted and displays an error. At present the errors for all the required fields are displayed in a long list at the top of my HTML form e.g. This field is required This field is required What I want to do, is place the error message under each required field e.g. this http://coreyworrell.com/assets/uploads/images/ajax_contact_form.png instead of this http://cdn1.1stwebdesigner.com/wp-content/uploads/2010/02/validation-ajax-css-form.jpg What do I need to do? My form looks similar to this at the moment: <div id="log"> <div id="log_res"> </div> </div> <form id="contact" name="contact" method="post" action="process.php"> <label>Name</label> <input type="text" name="Name" id="Name" tabindex="1" /> <label>Email</label> <input type="text" name="Phone" id="Phone" tabindex="2" /> </form> The error messages are placed in the <div> section at the top of the form (using ajax)
-
Hi, Please could someone help me out - I'm sure the answer is very simple, but basically I have two scripts which I need to combine so that they work in parallel. Unfortunately I can't provide the rest of the code just yet, but each works on its own but not both together (when placed side by side in the head of the document). The first: <script type="text/javascript" src="js/jquery-1.7.1.min.js" ></script> <script type="text/javascript"> /* <![CDATA[ */ $(document).ready(function(){ $("#Subject").change(function(){ if ($(this).val() == "form1" ) { $("#div1").slideDown("fast"); //Slide Down Effect } else { $("#div1").slideUp("fast"); //Slide Up Effect } }); $("#Subject").change(function(){ if ($(this).val() == "form2" ) { $("#div2").slideDown("fast"); //Slide Down Effect } else { $("#div2").slideUp("fast"); //Slide Up Effect } }); }); /* ]]> */ </script> The second: <script type="text/javascript" src="js/mootools.js"></script> <script type="text/javascript"> /* <![CDATA[ */ window.addEvent('domready', function(){ $('contact').addEvent('submit', function(e) { new Event(e).stop(); var log = $('log_res').empty().addClass('ajax-loading'); this.send({ update: log, onComplete: function() { log.removeClass('ajax-loading'); } }); }); }); /* ]]> */ </script>
-
Almost finished the front end, just need to add some validation now! I found a good script to show/hide content based on the selection of a drop down field - it may help someone! http://anthonygthomas.com/2010/03/14/display-form-fields-based-on-selection-using-jquery/
-
Good point Adam. I think it's going to be best to validate the form server side based on the option selected by the user, which in turn reveals that section of the form. Thanks!
-
Great, thanks. I shall take a look at a client side approach.
-
Hey everyone, I am looking to create an advanced contact form but need someone to point me in the right direction. I need to create a customer service form and would like it to contain the usual fields e.g. Name, Email etc. but also want to include a drop down field which has a couple of options e.g. Sales Enquiry, Order Status etc. Once one of those options has been selected e.g. Order Status, I then want a further section of the form to appear where the user can input data such as their order number, order date etc. Does anyone have any ideas on how to achieve this or know of any demos/scripts which they think might help.
-
I know I can go and do that, I was hoping that there was a way of doing it via the htaccess. Is it possible to include the full url to the error page in the ErrorDocument link of the htaccess?
-
Hi, In my .htaccess I have used the following code to provide an error page for my site: ErrorDocument 400 /error.php ErrorDocument 401 /error.php ErrorDocument 403 /error.php ErrorDocument 404 /error.php ErrorDocument 500 /error.php If I access a page which doesn't exist at www.example.com/unknownpage.php then the error page will appear formatted correctly with css etc. If I however access an unknown page in a subdirectory e.g. www.example.com/directory/unknownpage.php then the site will appear as text only without any formatting or image. I know this can be resolved by linking the css file via it's full URL (along with all the other media on the error page) is there a better more efficient way? Thanks
-
Thanks requinix - that works perfectly
-
Hello Would anyone be able to help with this small problem... I have 2 domains, www.example.co.uk and www.example.com They are configured by my host to share the same webspace What I would like however, is to use .htaccess to redirect a visitor who accesses the site via www.example.com to be redirected to www.example.co.uk I somehow need to add this into my existing .htaccess code which redirects a non-www domain to a www domain for SEO purposes Does anyone know how this may work? In summary - 2 domains pointing to the same shared directory. The .com domain (both http://www.example.com and http://example.com) need to redirect to www.example.co.uk The .co.uk (http://example.co.uk) must also redirect to the www version (http://www.example.co.uk) The code I currently have is below (this redirects non-www to www): RewriteEngine On RewriteBase / RewriteCond %{HTTP_HOST} ^example.co.uk [NC] RewriteRule ^(.*)$ http://www.example.co.uk/$1 [L,R=301] Any suggestions welcome
-
Is this the best way to extend the PHP session time?
lbh2011 replied to Bottyz's topic in PHP Coding Help
The idea of putting it into your script would be best. Could I suggest that you put it into config.php or where you define you server settings, then you don't need to put it on each and every page as it would be included each time. -
Could you explore using AJAX to keep all the information on the same page without having to reload it... then you wouldn't need to have a popup. Something like this may work for what you're trying to do: http://ajaxian.com/archives/asynchronous-file-upload-with-ajax-progress-bar-in-php
-
I had an interesting idea, but I don't know if it exsisted... Say for example if I had designed the CNN homepage, that clearly gets updated every few minutes with new news, if I wanted to show this in my portfolio as as example of a project I have designed, is there a way of creating a thumbnail or image of the site, which would be updated in real time to go along side the description? (I say real time, but I guess I mean every couple of hours or so) If anyone has seen anything like this or has any suggestions, let me know what you think!
-
Thanks! That sorted it. I must have changed a few bits with all this editing, but all works now!
-
Just to clarify, the issue is that if multiple records have the same location, and only the location filter is set, then multiple records should be displayed, not just the first.
-
I have had a chance to review the suggestions made, and have found that only one result is displayed when anything upto the number of records in the database should be. I assume this can be resolved using foreach() or similar function. The updated code is below, which has taken into account all the suggestions made in this forum. Any suggestion for how to get it working are welcome! <?php if(isset($_POST['searchage'])) { // Connects to your Database mysql_connect("host", "user", "pass") or die(mysql_error()); mysql_select_db("db") or die(mysql_error()); //Create where clause $postNames = array('searchage', 'searchlocation', 'searchgenre', 'searchinstrument', 'searchexperience'); $where_parts = array(); $where_clause = ''; foreach($postNames as $name) { if(isset($_POST[$name]) && trim($_POST[$name])!='') { $where_parts[] = str_replace("search", "user", $name)." = '".mysql_real_escape_string(trim($_POST[$name]))."'"; } } if(count($where_parts)>0) { $where_clause = " WHERE " . implode(' AND ', $where_parts); } $query = "SELECT * FROM musician_user {$where_clause}"; $result = mysql_query($query) or die(mysql_error()); $num = mysql_num_rows($result); echo "$num results found!<br>"; ($row = mysql_fetch_assoc($result)) ;{ if ($num != 0) echo " Name: {$row['username']}<br> Email: {$row['useremail']}<br> Age: {$row['userage']}<br> Location: {$row['userlocation']}<br> Genre: {$row['usergenre']}<br> Instrument: {$row['userinstrument']}<br> Experience: {$row['userexperience']}<br> Biography: {$row['userbiography']}<br><br> "; else echo "No results found"; } } ?>
-
You're right I could! but got that working so all is well! As I'm new here, do you know how I can mark this thread as solved? Thanks again.
-
Brilliant - It works! The only issue I have is that when no results are available, the script still displays the echo name, location, age part. is there an if statement which can be used to only display the records when the number of records is greater than 0? Thanks so much though!
-
I have put that in but get this output: SELECT * FROM musician_user 2 results found! Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /home/fluffyd1/public_html/online/muzomag/process.search.musician.php on line 28
-
Yes. The correct table is musician_user. I don't know if this could be the problem, but the field names in the form are called search??? and the column names in the table are called user??? could that be the issue?
-
I placed it just after the first mention of $query here: $query = "SELECT * FROM musician_user {$where_clause}"; echo "$query"; $result = mysql_query($query) or die(mysql_error()); $num = mysql_num_rows($result); The result in the browser was SELECT * FROM musician_user WHERE ArgyllUnknown column 'Argyll' in 'where clause'
-
I inserted echo "$query"; before echo "$num results found!<br>"; in the code above. It seems to generate the same error.
-
I'm not sure, I used the code mjdamato suggested above... can you work out whether this has what you mentioned?