Jump to content

mbtaylor

Members
  • Posts

    96
  • Joined

  • Last visited

    Never

Everything posted by mbtaylor

  1. Erm... headers need to be right at the top of the page if you havent got output_buffering on. Personally I use output_buffering (in php.ini) if you turn that to On then you wont get that error. Otherwise you would need to put the header code before any outputted html code (someone correct me if im wrong there).
  2. Id say its a blank page because you have turned off display_errors in your php.ini and there is a parse error or something. Turn display_errors on temporarily or look in your apache error_log to see whats wrong.
  3. As jesi said, strip_tags would work grand. If you want more control you are looking at regular expressions with preg_replace
  4. If you wanted a TOTALLY different page... you could use the browsers user agent string to work out which browser/device/version is accessing your page and use a location header to redirect the a different page/domain etc. Personally I think thats a crap way of doing it but its a choice I think the CSS method is good, or theres always XSLT...
  5. I believe there are lots of threads on this so do a search. But in short... SESSIONS!!!! Sessions are much more flexible, and have better security.
  6. I would do a preg_replace on the server side: $_POST['var'] = preg_replace ("/[^0-9]/", "", $_POST['var']); What that says is strip out anything that is not a number (0-9).
  7. I usually send a header to the browser: header ("Location: ".$_SERVER['PHP_SELF'].""); PHP SELF is the page you are on, or put in another location if you want to change to a different page.
  8. You might want to use the Heredoc method, I find it useful sometimes. You can use variables double and single quotes in a Heredoc print statement. Just make sure the last HTML; is on its own line with no whitespace infront of it or it wont work! Note the HTML can actually be any word (dont want to confuse you). Read the PHP Manual Print page for more information. print <<<HTML; <BR><BR> <table bordercolor="#F2DC77" border="1" align="center" width="600" cellpadding="1"> <form name="frmSearch" action="UpdateTeletext.php" method="post"> <tr><td bgcolor="#F8BC07" colspan="4" align="center">Record Fields...</td></tr> <td>OfferID: <input type="text" value="$row['Offer ID']" name="OfferID"/></td> <tr><td align="center">Price: <input type="text" name="Price" /></td> <td align="center">Flight: <input type="text" name="FLIGHTS" /></td> <td align="center">Accom: <input type="text" name="ACCOM" /></td> <td align="center">Total: <input type="text" name="TOTAL" /></td></tr> HTML;
  9. Just do a select for the username to check if it exists in the database before doing your insert like: <?php $self=$_SERVER['PHP_SELF']; $firstname=$_POST['first_name']; $surname=$_POST['sur_name']; $username=$_POST['user_name']; $password=$_POST['password']; $rpassword=$_POST['rpassword']; ?> A customer can register their details here: </p> <center> <form action="secret" method="post"> <div align="right">First Name: <input type="text" name="first_name" /> Last Name: <input type="text" name="sur_name" /> Username: <input type="text" name="user_name" /> Password: <input type="password" name="password" /> Re-enter Password: <input type="password" name="rpassword" /> <input name="submit" type="submit" /> </div> </form> </center> <?php if ($password == $rpassword){ $conn = mysql_connect( "secret","secret","secret" ) or die( "Err:Conn" ); $rs = mysql_select_db( "dombar0_work", $conn ) or die( "Err:Db" ); $sql = "SELECT username FROM users WHERE username='$username"; $rs = mysql_query( $sql, $conn ); if (mysql_num_rows ($rs)) { echo ("Please choose a different user name"); }else{ $sql = "INSERT INTO users ( first_name,sur_name,user_name,password ) VALUES ( \"$firstname\",\"$surname\",\"$username\", password(\"$password\") )"; $rs = mysql_query( $sql, $conn ); if ($rs){ echo( "Registration Complete $username!" ); } } } ?>
  10. Give a value to your checkbox. Then you can test for that value. I usually do: <input type='checkbox' name='whatever' value='1' /> #Then... if ($_POST['whatever'])print ("Whatever is checked"); That works for me
  11. is your database username really 'user'? Check your connection details
  12. Yes and make sure you check that $_POST['id'] is_numeric! Personally I use a regular expression like $id = preg_replace ("/[^0-9]/", "", $id); if ($id) { # do sql query } Always check your post vars (and any user input) for the right data or people WILL do nasty things to your database!
  13. I have had experience reading and writing to excel files. I highly recommend the use of the PEAR excel_writer class which is freely available from the PEAR website. Theres good documentation to it and its pretty easy to use. Use the directory iterator to loop through your directory looking for gif files etc then use the http://pear.php.net/package/Spreadsheet_Excel_Writer class to look through the excel file.
  14. I would have 2 tables. A table storing your bricks and a table storing your images (links to the image path). So there would be 2 primary keys brickID and imageID and a foreign key imageID in the brick table linking the correct image to the correct brick. It would then be just a case of doing a query with a join to display the bricks/images. $query = mysql_query ("SELECT * FROM bricks AS br INNER JOIN images AS im ON br.imageID=im.imageID"); Note dont use SELECT * just select the fields you want depending on your db structure
  15. My CMS architecture stores menus in a table. Each menu has a menuID and a related pageID. When displaying a page from the site, I lookup which page it is displaying (by the url matching it the the pageID) which then gives me which menu to show. In my menus table is a parent > child relationship. Some menus are children of the parent menu. This defines the menu heirachy. I use a recursive function to create the menus, looping through parent and child etc till all elements have been outputted. Design your database efficiently first, and your application will design itself
  16. That looks like the server is set to use authentification to me, which means you would have to send the login details.
  17. Im not quite sure what you mean, are you wanting to do address lookups by zip code? If so there are services that can do that. Or are you wanting to just select the appropriate option that relates? If so then I would look at the vars being posted and compare with the current value in the loop like: $selected = $db_countryID == $countryID ? " selected" : ""; print "<option value='$db_countryID'$selected>$country_name</option>"; You might need to use some hidden form fields maybe... not knowing what you are doing exactly.
  18. Or... foreach ($genres as $var => $value) { print ("$var = $value<br />"); } I tend to do this for converting db associative array values into variables. You can also use print_r like: print ("<pre>"); print_r ($genres); print ("</pre>"); If you want to sort your array, just use the sort function: sort ($array); Check the php manual for more information on array sort functions, theres a whole load of options.
  19. How I usually do that is use a bit of javascript on the select tag to submit the form like: <form name='myform'> <select name='something' onchange='document.forms.myform.submit()'> <option>Moo</option> </select> </form> Then look for the post variable 'something' and if it exists, you can use it to populate the db query that populates the next select element. Make sense?
  20. $url = $_POST['url']; print (create_url($url)); function create_url ($url) { if (!stristr ($url, "http://"))$url = "http://".$url; $httplink = "<a href='$url'>$url</a>"; return ($httplink); } Something like that?
×
×
  • 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.