PHP - Need Help With A Special Script
Hi guys, I am writing a "login" script that will be on my main page(I have it inside of <head></head> tags). I want it to take a user name and password, store it in a variable that is persistant with all pages on my website. Is that possible? How can I make a variable that will carry over to a page that doesn't have the original code? E,g, $Login = "alogin"; then when my client goes to a different page $Login still == "alogin"?
I hope this is understandable. I am not writing a very advanced script, I just want the input form to store the users login name/password so he or she may access a section of the site that has more options available if they're logged in. Similar TutorialsHi experts. I am received a GET variable into a page which is a id with a value as uuid:3242_2323_4444_9909_433/child_repeat[1]. Which is being used in my mysql query. So my query will be SELECT * from table_1 WHERE id = $id. However php is treating this string differently, my query fails, it says that it has a error near :3242_2323_4444_9909_433/child_repeat[1]. So it seems that its interpreting the colon as something else and removing the text before the colon.
Hi Hi everyone, I hope someone can give me an answer to problem that has eluded me for about 2 weeks. I just can not find the answer. My problem is that I have a database that I want to return the average of a column BUT the average number that gets calculated can not include the oldest two records that were entered in that particular column. In other words, if I have ten entries in a column only the latest 8 entries will be used to calculate the returned average. Here is the basic query I am using: Code: [Select] $result = mysql_query("SELECT *, avg(miles) AS av_miles FROM mpg WHERE vehicle_id='$id' "); Thank you for help in advance. How do I make it so if I get the question right, I have access to view the next page? For example, if I get this question right in index-1.php correct, it would take me to index-2.php (like in the script below), but if you don't get the question correct in index-1.php, you cannot have access/view index-2.php. Why I need this? Well, if you change the URL http://--------/index-1.php to http://--------/index-2.php, you can easily go from index-1.php to index-2.php without having to answer the question correctly. index-1.php: <?php if(isset($_POST['submit'])){ $number = $_POST['number']; if ($number == "elephant"){ header("Location: http://localhost/index-2.php"); exit();} } ?> <html> <head> <title>PHP Test</title> </head> <b>LEVEL 1</b> <body> <p> <font face="Courier New">c291cmNl</font> </p> <br/></body> </html> <form action="<?php echo $_SERVER['PHP_SELF'];?>" method="post"> Answer: <!-- "elephant" --> <input type="text" name="number" /><br /> </select> <input name="submit" type="submit"> </form> Thanks Code: [Select] <?php> $filename='http://www.example.com/polopoly_fs/1.1034350!/img/httpImage/image.jpg'; $size = getimagesize($filename); print $size; </php> If the image has symbol "!", it takes long time to execute the script. Please tell me how can we avoid this. I just came up with this idea I got for my registration script, where when the user has complete all steps in the registration process, he/she comes to a page that displays this: Code: [Select] <h1>Step 3: Activate your account</h1> <h2>Congratulations, <strong><?php echo $_SESSION["user"]["username"]; ?></strong>!</h2> <p>An email has been sent to <strong><?php echo $_SESSION["user"]["email"]; ?></strong> with an activation key, and important information regarding your account. Please check your email to complete registration.</p> Then this: Code: [Select] $email_client = preg_match ("/[@][a-zA-z0-9]{10}\.com$/", $_SESSION["user"]["email"]); $email_link = "<a href='http://www." . $email_client . ".com'>Go to " . $email_client . " mail now!</a>"; echo "<p class='center_align'>" . $email_link . "</p>"; Basically, what it does, is it figures out what email provider the user supplied as their email, and generates a link that allows them to go to that website, without having to type it in the address bar (I think I got that idea from facebook lol; only they probably do it differently). So anyway, It's not complete, and this is where I need someone's help... I assign a preg_match function to $email_client, so if it finds a string like "@yahoo.com", $email_client will be true, but that's not what I want. I want $email_client to equal a string, such as "yahoo" or "aol" based off of what the preg_match function finds, WITHOUT using if/else statements. Before I did an if/else statement for every email provider I could think of, but I think it better if I do it this way, as some people have crazy a** email names lol. So, basically what I want to do is this: Code: [Select] <?php //Step 1: Check email preg_match("/[@][a-zA-z0-9]{10}\.com$/", $_SESSION["user"]["email"]); //Step 2: Somehow assign the "a-zA-z0-9{10}" part to a variable //Step 3: Generate link with that variable used in the "href" attribute and the label ?> But I have no idea how to go about this...Help? I need to pass info to a php script via link while ignoring the character '&' for example: mywebsite.com/myphp.php?info=thisInformation&thecharacter& is there anyway I can tell php to ignore the character '&' and just read it as text (cause I understand its a special character.. maybe something like in XML you can ignore the character & by using <![CDATA[ ]]> thanks!!! much appreciated!!! PS: this is a must.. since in the end I am passing links.. and urls.. that are like amazon.com/blah&blah hello; I have: mysql: utf8_general_ci index.php: header( ... UTF-8) index.php: <meta ... content-type ... UTF-8> index.php, mysql query procedu ... mysql_set_charset( utf8 , .. ) ... So, if I put a special character in my db, it WILL display correctly in index.php But, if I put the same character in a php variable, it is BAD ... diamond-shape with question mark inside Since my special characters work from the db, I would like to also use them in html (index.php ). am I missing anything? thanks for your time .. Shannon I'm having a problem that I didn't seem to have in the past... for some reason, it just popped up... or maybe I'm just noticing it. Anyway, I this in a field in a mysql database: "Here's a test." When I query the database and echo the text to the page with this code: Code: [Select] $result = mysql_query("SELECT question FROM signin WHERE email = '$email'") or die (mysql_error()); $row = mysql_fetch_row($result); $test = $row[0]; echo $test; This is the result: "Heres a test." Any ideas on why the apostrophe is not being displayed and how to fix it? I'm stumped. Thanks for any help. Hello everyone! I'm working on a PHP employee database that uses the local network's active directory to allow users to log in. Basically, I'm using the ldap_bind command to authenticate and figure out what user is logging in. The main snippet of code is: Code: [Select] $username = $_POST['username']; $password = $_POST['password']; $convertedPassword = utf8_encode($password); if (ldap_bind($ds,"health1\\" . $username,$convertedPassword)){do stuff} This works fine for normal username/passwords, but has been getting hung up on special characters. I added the utf8_encode command, which allowed password with carrot (^) characters, but it still won't allow backslashes ( \ ). I get Code: [Select] Warning: ldap_bind() [function.ldap-bind]: Unable to bind to server: Invalid credentials in /var/www/emp/index.php on line 22 every time with a password such as "Blabla12\" The utf8_encode command seems to be escaping the \, which I think is what I want. Has anybody else had any luck with this? -Sam Code: [Select] $DB->query("SELECT id,name from ibf_members where name = '{$ibforums->input['to']}' LIMIT 1"); $e2 = $DB->fetch_row(); if ($e2['id']){ }else{ $std->Error2("Username doesn't exist dude"); } Ok, if I put in my username let's say 1of my users name is "$tabB" if I do that, it doesn't work is there a work around? Am trying to save a text input that require the use of some php special characters like (" ", ' ' ) e.t.c. When ever i post the data, the system returns an error. please, how can i go about this?
Thanks in advance
I hope this is a fairly quick one, I've got a form I'm building where i may well have some special characters being inserted (accents mostly) now normally i would just pop in an HTML editor (TinyMCE) and let that deal with it. But i am looking to export this data as a CSV for use in excel, which means i can't afford to have HTML tags within the output. I am sure someone will have come across this before any suggestions? many thanks Matt |