Jump to content

DavidAM

Staff Alumni
  • Posts

    1,984
  • Joined

  • Days Won

    10

Everything posted by DavidAM

  1. primefalcon: I have sent both in a form before. If there is a querystring in the ACTION attribute they show up as $_GET variables. I discovered this when I was trying to add some (apache) mod_rewrite and using ACTION="". If the re-write gives the browser the url with a querystring and the ACTION="", then you get that querystring when you POST the form. Just thought I'd mention it. As to the OP's problem, I have to agree with you, probably another form that was not closed.
  2. You can put anything you want (almost) inside the message: (I have rearranged the code just to make my point clearer. Each value is on a separate line (as it is in the email), so just add the literals in that you want: $pBerichtUser = 'Het volgende bericht heb je verstuurd via contact formulier:<br><hr><br>' . "Name: " . $_POST['naam'] . "</br>" . "Surname: " . $_POST['voornaam'] . "</br>" . "Address: " . $_POST['adres'] . "</br>" . "Post Code: " . $_POST['postcode'] . "</br>" . "Gender: " . $_POST['gemeente'] . "</br>" . "Telephone: " . $_POST['Telefoon'] . "</br>" . "No Idea: " . $_POST['Telav'] . "</br>" . "EMail: " . $_POST['email'] . "</br>" . "Underwear?: " : $_POST['onderwerp'] . "</br>" . "Be Rich?: " . $_POST['bericht']; mail($_POST['email'],$cOndPre.' '.$_POST['onderwerp'].' '.$cOndSuf,$pBerichtUser,$pHeader); Forgive my translations, I only speak English. I hope I didn't insult anybody.
  3. OK, it helps when you explain the problem and what you want to happen. The images display one at a time because the browser has to retrieve them from the server one at a time. There are two ways I can think of to accomplish what you want. (There may be others, but this is what I know) 1) Use image processing commands to create a single image. This will take the server a while, so the page will appear to load slowly on slow computers, but it will be a single image. Of course, then you have to deal with these image files cluttering up your disk space on the server. 2) Hide the DIV or TD or whatever holds these images. Then use javascript to unhide the DIV in the BODY's onLoad event. This will cause the images to all show at once, I think. A third approach with a little different imapact would be to set all 24 images to the default, these will load quickly because the browser can retrieve a single image to show in all 24 places. Then use Javascript to replace the ones you want replaced. This will have the affect of showing the images one at a time, but they will be positioned properly as they load replacing the default image. This may be rather complicated. If you are concerned about the page re-arranging itself each time an image comes in, set the WIDTH and HEIGHT attributes of the IMG tag, so the browser will allocate the space before requesting the images. This is the easiest solution (IMHO) and will probably provide the best look.
  4. What exactly do you mean by "putting it all into one image"? Are you wanting to create a single image so you can output a single IMG tag to show all 24 images? You will have to look into the image processing functions (http://us.php.net/manual/en/refs.utilspec.image.php). I have no experience with them so I can't help further. Since you have an anchor around the ones that came from the database, I assumed you wanted it to APPEAR to be one image but actually be 24 different images allowing selection. To make them APPEAR to be a single image, you will have to remove all spacing between them. Spacing between elements comes from the MARGIN and/or PADDING and/or BORDER. So that will take some CSS or in-line STYLE commands.
  5. In you form snippet, <input type="text" name="telefoon" size="40" value="<?= $pTelefoon; ?>"> <input type="number" name="telefoon savonds" size="40" value="<?= $pTelav; ?>"> telefoon is NOT capitalized but in your mail snip $pBerichtUser = 'Het volgende bericht heb je verstuurd via contact formulier:<br><hr><br>'.$_POST['naam']."</br>".$_POST['voornaam']."</br>".$_POST['adres']."</br>".$_POST['postcode']."</br>".$_POST['gemeente']."</br>".$_POST['Telefoon']."</br>".$_POST['Telav']."</br>".$_POST['email']."</br>".$_POST['onderwerp']."</br>".$_POST['bericht']; mail($_POST['email'],$cOndPre.' '.$_POST['onderwerp'].' '.$cOndSuf,$pBerichtUser,$pHeader); it is "$_POST['Telefoon']". So you are working with two different variables here.
  6. To get the row to break at 8, use the following right after incrementing num_printed: $num_printed += 1; if ( ($num_printed % == 0) echo '<BR />'; You are probably going to have to use a little CSS to style the A, IMG and BR, to remove any spacing between the images (margin, padding, border) so they will line up
  7. Ahh! Good point! I had not thought about that (more than one space side by side), I can see where visually that would be confusing. Yes, you can put more than one function in a php file. Then include that file on each page that needs it. I try to combine common functions (used on lots of pages) in one file (funcCommon.php). Functions that are only used on a couple of pages go into separate files (say funcUsers.php, funcProd.php) then I only include the file(s) I need in the pages I need them. Yes you can extend to handle multiple characters. function validUsernameChars($username) { if ( (strpos($username, ' ') !== false) or (strpos($username, '<') !== false) or (strpos($username, '>') !== false) ) { return false; } else { return true; } } This could get tedious and look ugly if there are lots of characters you don't want. An easier way might be: function validUsernameChars($username) { $bad = array(' ', '<', '>'); if (str_replace($bad, '#', $username) != $username) { return false; } else { return true; } } The idea here is that if I replace bad characters with anything (or nothing) then the result is not equal to the original, so there were some bad characters in there. Using a function instead of putting the check directly into your code gives you more flexibility. Even if you only do this in one place. If you later decide that all user names MUST have atleast ONE digit, you add that check in the function and you are done.
  8. $result4 = odbc_exec($database2,$insert $values); should probably be: $result4 = odbc_exec($database2,$insert . ' ' . $values);
  9. dirkers is correct. The OP was asking about undefined variables. If you use if(!$user) and the variable is not defined, PHP will throw an error.
  10. I don't know why websites choose to not allow a space in the user name. A space is just a character, after all, and (IMHO) should be valid. But if you want to disallow say, 'David A M' (see the spaces), then you can use strpos(). Although you might want to consider adding another function (or including it in your existing function - which would mean you would have to change the error message a little. If you create a new function, say "validCharsUsername()" then if you later decide to not allow other characters, you change the function instead of adding another strpos() everywhere that you do the check. ** Untested code ** if ( empty($username) ) { $error['username_error'] = '<div class="formerror">Please enter your username</div>'; } // Add these lines elseif (strpos($username, ' ') !== false) { $error['username_error'] = '<div class="formerror">Invalid characters in username.</div>'; } elseif (!validUsername ($username) ) { $error['username_error'] = '<div class="formerror">Username Taken please choose another.</div>'; } another way to accomplish this is to use str_replace(). Replace all unwanted characters with something (or nothing) and compare the result with the original string. If they match, it's OK, if they don't, it's invalid. if (str_replace(array(' ', '<', '>'), '', $username) != $username) { // Invalid characters in username }
  11. Your link is not properly formed. the HREF attribute indicates that a new page should be opened. When the window.open() funtion runs, it returns an object, and that is what the white page is telling you. I'm not sure you can accomplish this with HREF. You could use the ONCLICK attribute (instead of the HREF) but then you might not get the visual indicators that it is a link (use CSS to change the style of that link). <a onclick="window.open('page.php','name1','height=320,width=240');">pop-up</a>
  12. I like the overall look and feel of the site. I have to agree with oni-kun on the email. When I see a business with a gmail or yahoo or other email service address, I immediately think "small time -- This is an individual NOT a business" and I would be hesitant to use them. If you have your own domain name, your host probably allows at least one email address at that domain. Even if you set it up to just forward to your gmail, it will give a more professional impression. Also change the wording slightly on the synopsis. On the right you say "contact us" but on the left you say "Robert has been ...". On one hand you imply a company on the other an individual. Change the wording to something like "Roberts Plumbing has over 26 years experience in the field ..." If possible, add descriptions to the pictures, use the "TITLE" attribute of the IMG tag on the main page, and, if possible, add a description on the popup image. That shower looks cool, but the water heater is not very exciting, tell me something about what makes it special enough to be on your home page - not a long story, just the specs or something. If those are new installations, say so -- "500 gallons of hot water in 5 seconds" or whatever Another thing that may put people off is that the "site" has only one page. Think about how you can expand it to a few more. Don't break it in the process, through. See if he has some before and after pictures - like a blownup water heater (before) and the beautiful job he did to replace it (after). This could make a series of additional pages showing work he has done. I have to scroll to see all of the service area. Move the contact stuff to the bottom of the right column so the service ares are all visible without scrolling. I am not hating on your site. I really like the look, it is very well done. I am NOT a design expert, all of these suggestions are from the perspective of a consumer looking at a website. Good luck.
  13. The query may not be returning any rows, in which case your script does not produce any output. After executing the query, add a check to see if it succeeded: if ($official2 === false) { echo 'Query Failed: ' . mysql_error(); }
  14. You should be getting error messages or warnings. In the first few lines of code you are using falsestart as an array key. It is not in quotes, so PHP is looking for a named constant. If it does not find one, it reports a warning and treats it as a string. If you set error_reporting(E_ALL); you should be seeing these error messages. When you get the white page, use the View Source feature in your browser and see if there is any output at all. If there is some output that starts with an angle-bracket ('<') the browser would consider it an unknown HTML tag and NOT display everything inside the brackets.
  15. Actually, if LittleString is at the beginning of BigString, then strpos() will return zero which will evaluate to false. So you need to check for equivalence: if(strpos($bigstring, $littlestring) === false) { // Do something
  16. Oops, I didn't read the code very clearly did I? Sorry, about that. As to your current problem, I have had this problem (with mysql) as well. odbc_exec() returns a resource, which is essentially an integer. I have had it return a valid resource with an integer value of zero and therefore the if ($res) fails (zero is false). So I now test all of my exec()'s using: $res = exec_sql(...); if ($res === false) { // IT FAILED } else { // IT WORKED -- imagine that } the three equal signs in the IF statement mean that the statement will only be TRUE if the values are the same AND have the same data type. If you want to have the WORKED part first and the FAILED part last you can turn it around if ($res !== false) { // IT DID NOT FAIL } else { // CRIPES! FOILED AGAIN! } that's two equal signs after the bang (!)
  17. That solution (by DJTim666) requires that your users have JavaScript enabled and will not do anything if it is not. Your original solution that produced an error should work if you fix the quotes. Your entire ECHO string is inside double quotes, so you can't have double quotes inside it unless you escape them. Change them to single quotes INSIDE the string and it should work.
  18. Or, you could continue this discussion by describing the "columns" of data you are proposing and we can help you break it up into tables, if necessary. ignace's statement to use multiple tables may or may not be correct. If all of the columns are specific data about the user, a single table could be appropriate. If the columns include products purchased or other data not specific to the user, then there are multiple tables in the database. However, I can easily see a user table with 20 or more columns of user-specific data. Without knowing what the proposed data elements are, and the proposed system, we can't really answer the question. Ordinarily, there should be one AND ONLY one USER table with each user listed in that table.
  19. To do this in PHP, you need to do the insert inside your fetch loop: // THIS IS PSUEDO-CODE DO NOT COPY AND PASTE $sqlFind = 'SELECT * FROM projectTable1 WHERE id = ' . $projID; $resFind = execute_query($sqlFind); while ($rowFind = fetch($resFind)) { $sqlIns = 'INSERT INTO projectTable2 ...'; $resIns = execute_query($sqlIns); if ($resIns) { $sqlDel = 'DELETE projectTable1 ...'; execute_query($sqlDel); } else { echo 'INSERT failed ...'; break; } } Do NOT DELETE the data until you check the status of the INSERT execution and are satisfied that it was successful. However, if the tables are on the same connection, you can just copy them in sql: INSERT INTO projectTable2 (column names here) SELECT column names FROM projectTable1 WHERE ID = ... Then do the DELETE in a separate query call. I would wrap it all in a TRANSACTION and verify that the INSERT and DELETE operated on the same number of rows to make sure that no data is lost.
  20. You are executing the query OUTSIDE of the function. $sql is NOT defined in that scope so the query is empty. You probably want to execute the query inside the function after assigning $sql
  21. I think the $_GET variables are automatically url_decoded so you use a space instead of the %20. I'm not 100% sure of that, but it is worth a try. If it does not work, try echoing out the $orgname after you pull it from the $_GET array: $orgname = $_GET['orgname']; echo $orgname; you may have to look at the source (View->Page Source) because the browser may interpret HTML characters rather than display them.
  22. I have never tried to do this, but I know there are php.ini settings to allow (or not allow) opening a url as if it is a file. See http://us3.php.net/manual/en/filesystem.configuration.php#ini.allow-url-fopen. Apparently, with Windows there are some limitations. If the file you are trying to access is on your system, use a file path instead of a url (it is probably more efficient and therefore faster). If it is not on your system, you may be stuck.
  23. Your SELECT statement contains the literal '$qu' NOT the value of the variable named $qu. It looks like you are trying to bind the PHP variable to the SELECT statement. I don't do binding (don't even know how or if it is possible). Change that way you setup your $find array to put the value into the string: if (!empty($_POST['quantity'])) { $qu = mysqli_real_escape_string($dbc, trim($_POST['quantity'])); if ($count == 0){ $find[$count] = " quantity='" . $qu . "'"; $count ++; }else{ $find[$count] = " AND quantity='" . $qu . "'"; $count ++; } }
  24. Its OK. We were all new to PHP at some time. First, since you are new, put these two lines at the top of any page that has php: error_reporting(E_ALL); ini_set('display_errors', 1); that will tell PHP to show you any errors or warnings that result from your code. This will help you find and fix bugs. Second, when writing a page that posts to itself (as yours is doing), I highly recommend processing the post at the beginning of the script, then output the HTML at the end. So it would look something like this: <?php error_reporting(E_ALL); ini_set('display_errors', 1); if (isset($_POST['MySubmitButtonName'])) { // process the submitted form here } // Now build the 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> <!-- and so forth --> This keeps your code logically grouped together so it is easier to develop and maintain. Also, it will prevent the problem you are having. The problem is that the header("Location: ...") call is telling PHP to send a header. However, you have other output above that. Once you send text (whether it is HTML or just output from an echo statement), PHP sends all of the headers before it. After that you cannot send any more headers, so your attempt to redirect after the POST processing is failing; but you don't see the error message because you don't have them turned on.
  25. You have all of the items in separate forms, and they are separate from the one with the contact information. When you click a submit button ONLY the FORM that contains that button is submitted. Make the whole page ONE big FORM and you should be good to go.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.