Jump to content

alpine

Members
  • Posts

    759
  • Joined

  • Last visited

Everything posted by alpine

  1. Try this one, note that it's case sensitive: [code] <?php if(!empty($_POST["starter"])) { $starter = strip_tags($_POST["starter"]); $choosable = array("pikachu","charmander","bulbasaur","squirtle"); if (!in_array($starter, $choosable)) { echo "You may not choose a starter that is not on the list!"; exit(); } else {   // ok } } else {   // $starter contains no data } ?> [/code] Note: Since PHP 4.1.0 you should use $_POST instead of $HTTP_POST_VARS when retrieving posted variables (also on GET, COOKIE etc, consult the [a href=\"http://no.php.net/manual/en/reserved.variables.php\" target=\"_blank\"]manual[/a]
  2. you are missing some [!--coloro:#CC0000--][span style=\"color:#CC0000\"][!--/coloro--];[!--colorc--][/span][!--/colorc--] and it should give you a error msg when loading the php file, doesn't it? Also missing some double quotes in your src - [!--coloro:#CC0000--][span style=\"color:#CC0000\"][!--/coloro--]"[!--colorc--][/span][!--/colorc--] <TD COLSPAN="2" WIDTH=[!--coloro:#CC0000--][span style=\"color:#CC0000\"][!--/coloro--]"[!--colorc--][/span][!--/colorc--]<?php echo $TABLEWIDTH[!--coloro:#CC0000--][span style=\"color:#CC0000\"][!--/coloro--];[!--colorc--][/span][!--/colorc--] ?>[!--coloro:#CC0000--][span style=\"color:#CC0000\"][!--/coloro--]"[!--colorc--][/span][!--/colorc--] ALIGN="center"> <img src=[!--coloro:#CC0000--][span style=\"color:#CC0000\"][!--/coloro--]"[!--colorc--][/span][!--/colorc--]<?php echo "title.jpg"[!--coloro:#CC0000--][span style=\"color:#CC0000\"][!--/coloro--];[!--colorc--][/span][!--/colorc--] ?>[!--coloro:#CC0000--][span style=\"color:#CC0000\"][!--/coloro--]"[!--colorc--][/span][!--/colorc--]></td> i still cannot understand why you are echo'ing a hard coded img name, assume its just for this example code...
  3. I would suggest to try this in Login.php and see what u get: [code] $sql = mysql_query("SELECT `code` FROM `jos_users`  WHERE code = '$code' AND activation = 'yes'") or die(mysql_error()); [/code] it's also good coding in my sense -to check that the form is infact posted and that the posted variable(s) actually contains data before querying the database. also, If your posted code should containg only numbers, you could use the is_numeric() function to validate the posted string's contents
  4. I have no experience in use with other mailsystems, i'm sure anyone can point you in some direction there. But You might want to check if you have the option with your host to sendt through smtp, this would give you better score in the X-Spam-Status. Hotmail is one of the most difficult mailboxes to make friends with, however the first thing is to set your email header information as properly and complete as possible. I also think hotmail verifyes incoming email with sender ID, you can read more about it [a href=\"http://www.microsoft.com/mscorp/safety/technologies/senderid/overview.mspx\" target=\"_blank\"]HERE[/a] and its - as i understand - connected with sender policy framework ( [a href=\"http://www.openspf.org/\" target=\"_blank\"]http://www.openspf.org/[/a] )
  5. ramped-aids99, unfortenately no-one is able to tell you all of this in one post like you are asking - the subject is way too wide for that. You simply have to learn to fully handle html (or xhtml) first, then start your way with php - then move further into joining php and mysql database together to store data. I suggest you start with your html page and then come back with specific php related questions as you are working your way to your goal. There is no magic trick, you just have to start learning, understanding, digging for solutions and DO the working.
  6. 1: You can use $_POST for this [code] if(isset($_POST['submit'])) { $field_1 = htmlspecialchars($_POST['field_1']); } else { echo <<<__HTML_END <form action="page.php" method="post"> Field 1: <input type="text" name="field_1" value="" size="30" /> <input type="submit" name="submit" value="Submit Form" /> </form> __HTML_END; } [/code] 2: add single quotes around $user, mysql_query("UPDATE points SET points = points + 5 WHERE user_name= [!--coloro:#CC0000--][span style=\"color:#CC0000\"][!--/coloro--]'[!--colorc--][/span][!--/colorc--]$name[!--coloro:#CC0000--][span style=\"color:#CC0000\"][!--/coloro--]'[!--colorc--][/span][!--/colorc--]") or die(mysql_error());
  7. Try this: [code] ob_start(); require("receiptcode.php"); $msg = ob_get_contents(); ob_end_clean(); [/code]
  8. Like this: [code] <head></head> <body> Headline info or whatever goes here <?php if ($handle = opendir('.')) { while (false !== ($file = readdir($handle))) { if ($file != "." && $file != "..") { echo "<img src='".$file."'>"; } } closedir($handle); } ?> Footer or whatever goes here </body> [/code] your parse error must be a cut'n paste error or something...
  9. One very basic example - look it up in the [a href=\"http://www.php.net\" target=\"_blank\"]Manual[/a], put this in a file in the folder with your images - and call the file [code] if ($handle = opendir('.')) { while (false !== ($file = readdir($handle))) { if ($file != "." && $file != "..") { echo "<img src='". $file."'>"; } } closedir($handle); } [/code]
  10. you can actually do this with htaccess aswell (least on my host's server setup), i have something similar to this in my .htaccess (note: NOT full url): ErrorDocument 404 /index.php?page=404_error ErrorDocument 403 /index.php?page=403_error and in index i use switch to load the 403/404 pages i made. When i hit for example www.mydomain.no/jhgfaqgfa - the htaccess loads the index switch while the url still is the same as when mistyped - no change. by using $_SERVER['REQUEST_URI'] in your 403/404 document, you can split and use whatever is in the adress bar.
  11. you are trying to use $_GET['story_id'] inside an if condition only to run when there is no $_GET['story_id'] set if([!--coloro:#FF0000--][span style=\"color:#FF0000\"][!--/coloro--]![!--colorc--][/span][!--/colorc--]isset($_GET['story_id'])) { $result = mysql_query("Update cms_stories set section='$section', added_by='$added_by', headline='$headline', byline_name='$byline_name', appeared='$appeared', opening='$opening', body_text='$body_text', picture='$picture', pic_caption='$pic_caption', pic_ref='$pic_ref', notes='$notes' where story_id=".[!--coloro:#FF0000--][span style=\"color:#FF0000\"][!--/coloro--]$_GET['story_id'][!--colorc--][/span][!--/colorc--]); $msg = "The Story record has been updated in the database - Please Click <a href=\"menu.php\">Here</a> to return to the main menu"; } so that wont work
  12. Yes you can - or you can make it compatible with both by using different GET calls [code] if(!empty($_GET['html'])) { $view = htmlspecialchars($_GET['html']); $page = "path/".$view.".html"; } elseif(!empty($_GET['php'])) { $view = htmlspecialchars($_GET['php']); $page = "path/".$view.".php"; } else { $page = "path/welcome.html"; } if(file_exists($page)) { include ($page); } else { print "Page not found"; } [/code] Either call it with --> index.php?html=about <-- that will include --> about.html OR call it with --> index.php?php=about <-- that will include --> about.php
  13. change [code] $query = mysql_query($querystring); [/code] to [code] $query = mysql_query($querystring) or die(mysql_error()); [/code] and it will probably point you in the right direction (WHERE what = 1 ??)
  14. you need to tell it where to update [code] update tablename set col1 = '$value1', col2 = '$value2'  where rowid = '$id' [/code]
  15. but work on the following posted code: [a href=\"http://www.phpfreaks.com/forums/index.php?s=&showtopic=92839&view=findpost&p=371846\" target=\"_blank\"]http://www.phpfreaks.com/forums/index.php?...ndpost&p=371846[/a] I see you have fallen back to another one :) Remember also that when you set/start a new session, it wont take effect untill the next pageload, meaning setting a session and using it on the same code without reloading the page wont work - i am beginning to think you might have several different issues that all needs to be fixed - so start with one code and work your way.
  16. using mysql INTERVAL might help you out, it's much easier. Storing time using NOW() + INTERVAL add or sub example: [code] mysql_query("select * from table where stampedtime < date_sub(now(), interval 5 minute)"); [/code] [a href=\"http://www.mysqlfreaks.com/statements/53.php\" target=\"_blank\"]http://www.mysqlfreaks.com/statements/53.php[/a]
  17. try changing --> require_once('../../Connections/connBSD.php'); to --> require('../../Connections/connBSD.php'); I've seen this problem in another thread some time ago, the "once" makes fuzz sometimes - Also change your content of connBSD.php to this(inserting your names and passwords ofc): [code] $hostname_connBSD = "xxxx"; $database_connBSD = "xxxx"; $username_connBSD = "xxxx"; $password_connBSD = "xxxx"; $connBSD = mysql_connect($hostname_connBSD, $username_connBSD, $password_connBSD) or trigger_error(mysql_error(),E_USER_ERROR); $selectDB = mysql_select_db("$database_connBSD") or die("Unable to select db"); [/code] -
  18. could you provide how you connect to your db, and if you are including this as a file with include(), require(), require_once() etc. using --> require("path/dbfile.php"); where dbfile.php contains my previous db connection setup is tested and is working. Form action you put to $_SERVER[PHP_SELF] or the actual name you have chosen for this file, for example "update_welcome.php" or whatever. ? so - you still have your wife ??!!!! *lol*
  19. If your session username finds a valid user it should work - the code i suplied has form action pointed on itself - one file handling both view stored and update. You dont get any mysql errors either ?? ** edit ** i see your edited post about no db selected, how do you connect then?? Like this works: [code] $dbhostname = "xxx"; $dbuser = "xxx"; $dbpassword = "xxx"; $db = "xx"; $connect = mysql_connect($dbhostname, $dbuser, $dbpassword) or die("unable to connect to db"); $choose = mysql_select_db("$db") or die("Unable to select db"); [/code]
  20. It depends on how your site is build, and if i understand you correctly you currently only have text files. Then the answer is YES if you want to use switch like in my example above. You can do a different twist and include files based on GET variable directly - BUT do it with caution as it is in some cases very vounerable to url injection attacs, example if all your include pages end with .html: [code] $view = htmlspecialchars($_GET['view']); $page = "path/".$view.".html"; if(empty($view)) { include ("path/welcome.html"); } else { if(file_exists($page)) { include ($page); } else { print "Page not found"; } } [/code] Then call it with --> index.php?view=about <-- that will include --> about.html
  21. hi again, dont worry - we are solving a problem. As to the parse error i forgot (sorry) to end a variable set with [!--coloro:#FF0000--][span style=\"color:#FF0000\"][!--/coloro--];[!--colorc--][/span][!--/colorc--] Now - as to your fetch array warning, this (also your previous num_rows problems) indicates a problem when querying against the database - are you 100% sure there are no misspelling in column names used?? By adding a @ only means it wont print out the warning msg, it still fails like when you are getting the warning printed out - surpress errors with caution (don't mis-use @) The following i have tested with hard coded username - and it works 100% every time. Test it and see what u get, i've added mysql_error(): [code] <?php // require("secret/db_connection.php"); // $kt_login_user = "tom"; // replaces the SESSION to test echo $kt_login_user; if(isset($_POST['update'])) { $new_msg = htmlspecialchars($_POST['welcome']); $sql = mysql_query("update users set welcome = '$new_msg' where username = '$kt_login_user'") or die(mysql_error()); if(mysql_affected_rows()==1) {   print "<b>Text updated!</b><br />"; } else {   print "<b>Warning: no changes where made</b><br />"; } } $qry = mysql_query("SELECT welcome FROM users WHERE username = '$kt_login_user'") or die(mysql_error()); if(mysql_num_rows($qry)==1) { $r = mysql_fetch_array($qry); $kt_welcome = $r['welcome']; } else {   print "<b>Warning: unique user not found</b><br />"; } if(!$kt_welcome) { $kt_welcome = "My default text"; } echo <<<__HTML_END <form method="post" action="this_page.php"> <textarea name="welcome" cols="80" rows="20">$kt_welcome</textarea> <br /> <input type="submit" name="update" value="Save" /> </form> __HTML_END; mysql_close(); ?> [/code]
  22. I suggest switch statement instead of frames, like this [code] <?php // top layout here, or include header file switch ($_GET['view']) { case 'about': include ("path/about.html"); break; case 'news': include ("path/news.php"); break; default: include ("path/welcome.php"); break; } // footer layout here, or include footer file ?> [/code] You see the pattern, if this is called index.php , calling --> index.php?view=about <-- would include about.html As to the news-bar, once you get more familiar with php i suggest mysql database to store news and then get news from the database as many ways as you wish :)
  23. something like this is one simplified way of doing it [code] if(!empty($_GET['url'])) {   $url = htmlspecialchars($_GET['url']);   mysql_query("update links set hits = hits + 1 where url='$url'");   header("Location: $url");   exit(); } $get_links = mysql_query("select url from links"); while($row = mysql_fetch_array($get_links)) {   $url = $row['url'];   print "<a href="this_page.php?url=$url" target="_blank">$url</a>";   print "<br />"; } [/code]
  24. do a check to see if it exists, like for example this: [code] if(file_exists("path/icon.gif")) { print "<img src=\"path/icon.gif\" alt=\"icon\" />"; } else { print "This file does not exist.."; } [/code]
  25. you must provide your code to get help on this, we cannot guess what you are currently using or even what you are trying to do
×
×
  • 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.