Jump to content

Search the Community

Showing results for tags 'noob'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to PHP Freaks
    • Announcements
    • Introductions
  • PHP Coding
    • PHP Coding Help
    • Regex Help
    • Third Party Scripts
    • FAQ/Code Snippet Repository
  • SQL / Database
    • MySQL Help
    • PostgreSQL
    • Microsoft SQL - MSSQL
    • Other RDBMS and SQL dialects
  • Client Side
    • HTML Help
    • CSS Help
    • Javascript Help
    • Other
  • Applications and Frameworks
    • Applications
    • Frameworks
    • Other Libraries
  • Web Server Administration
    • PHP Installation and Configuration
    • Linux
    • Apache HTTP Server
    • Microsoft IIS
    • Other Web Server Software
  • Other
    • Application Design
    • Other Programming Languages
    • Editor Help (Dreamweaver, Zend, etc)
    • Website Critique
    • Beta Test Your Stuff!
  • Freelance, Contracts, Employment, etc.
    • Services Offered
    • Job Offerings
  • General Discussion
    • PHPFreaks.com Website Feedback
    • Miscellaneous

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Age


Donation Link

Found 10 results

  1. Hello all, It's my first time here, I hope you will be indulgent. I am trying to create a contact form in php, using something that a former employee at my company has written for another website. Please note that I have no knowledge whatsoever of php (except what I've learned while creating it...). Here is the code I am working with. Can you go through and let me know if see anything that seems off to you? Thank you very much! <?php /* ******************************************************************************************** CONFIGURATION ******************************************************************************************** */ // destinataire est votre adresse mail. Pour envoyer à plusieurs à la fois, séparez-les par une virgule $destinataire = 'myemail'; // copie ? (envoie une copie au visiteur) $copie = 'oui'; // Action du formulaire (si votre page a des paramètres dans l'URL) // si cette page est index.php?page=contact alors mettez index.php?page=contact // sinon, laissez vide $form_action = ''; // Messages de confirmation du mail $message_envoye = "Votre message nous est bien parvenu. Merci !"; $message_non_envoye = "L'envoi du mail a échoué, veuillez réessayer SVP."; // Message d'erreur du formulaire $message_formulaire_invalide = "Vérifiez que tous les champs soient bien remplis et qu'il n'y ait pas d'erreur dans votre adresse courriel."; /* ******************************************************************************************** FIN DE LA CONFIGURATION ******************************************************************************************** */ /* * cette fonction sert à nettoyer et enregistrer un texte */ function Rec($text) { $text = htmlspecialchars(trim($text), ENT_QUOTES); if (1 === get_magic_quotes_gpc()) { $text = stripslashes($text); } $text = nl2br($text); return $text; }; /* * Cette fonction sert à vérifier la syntaxe d'un email */ function IsEmail($email) { $value = preg_match('/^(?:[\w\!\#\$\%\&\'\*\+\-\/\=\?\^\`\{\|\}\~]+\.)*[\w\!\#\$\%\&\'\*\+\-\/\=\?\^\`\{\|\}\~]+@(??:(?:[a-zA-Z0-9_](?:[a-zA-Z0-9_\-](?!\.)){0,61}[a-zA-Z0-9_-]?\.)+[a-zA-Z0-9_](?:[a-zA-Z0-9_\-](?!$)){0,61}[a-zA-Z0-9_]?)|(?:\[(??:[01]?\d{1,2}|2[0-4]\d|25[0-5])\.){3}(?:[01]?\d{1,2}|2[0-4]\d|25[0-5])\]))$/', $email); return (($value === 0) || ($value === false)) ? false : true; } // formulaire envoyé, on récupère tous les champs. $name = (isset($_POST['name'])) ? Rec($_POST['name']) : ''; $email = (isset($_POST['email'])) ? Rec($_POST['email']) : ''; $tel = (isset($_POST['tel'])) ? Rec($_POST['tel']) : ''; $sujet = (isset($_POST['sujet'])) ? Rec($_POST['sujet']) : ''; $message = (isset($_POST['message'])) ? Rec($_POST['message']) : ''; // On va vérifier les variables et l'email ... $email = (IsEmail($email)) ? $email : ''; // soit l'email est vide si erroné, soit il vaut l'email entré $err_formulaire = false; // sert pour remplir le formulaire en cas d'erreur si besoin if (isset($_POST['envoi'])) { if (($name != '') && ($tel != '')) { // les 4 variables sont remplies, on génère puis envoie le mail //$headers = 'From:'.$name.' <'.$email.'>' . "\r\n"; //$headers .= 'Reply-To: '.$email. "\r\n" ; //$headers .= 'X-Mailer:PHP/'.phpversion(); $headers = "From: " . $name . "\r\n"; $headers .= "Reply-To: ". $email . "\r\n"; $headers .= "MIME-Version: 1.0\r\n"; $headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n"; // envoyer une copie au visiteur ? if ($copie == 'oui') { $cible = $destinataire.';'.$email; } else { $cible = $destinataire; }; // Remplacement de certains caractères spéciaux $message = str_replace("'","'",$message); $message = str_replace("’","'",$message); $message = str_replace(""",'"',$message); $message = str_replace('<br>','',$message); $message = str_replace('<br />','',$message); $message = str_replace("<","<",$message); $message = str_replace(">",">",$message); $message = str_replace("&","&",$message); // Envoi du mail $num_emails = 0; $tmp = explode(';', $cible); foreach($tmp as $email_destinataire) { $msg = '<html><body>'; $msg .= '<h1>Vous avez reçu une soumission</h1>'; $msg .= '</body></html>'; $msg = '<html><body>'; $msg = '<h3>Formulaire : </h3>'; $msg .= "<tr><td><strong>Prénom Nom : </strong> </td><td>" . $name . "</td></tr>"; $msg .= "<tr><td><strong>Courriel : </strong> </td><td>" . $email . "</td></tr>"; $msg .= "<tr><td><strong>Téléphone : </strong> </td><td>" . $tel . "</td></tr>"; $msg .= "<tr><td><strong>Sujet : </strong> </td><td>" . $sujet . "</td></tr>"; $msg .= "<tr><td><strong>Message :</strong> </td><td>" . $message . "</td></tr>"; } $msg .= "</table>"; $msg .= "</body></html>"; //$msg = $name.'</br>'.$email.'</br>'.$tel.'</br>'.$sujet.'</br>'.$message; if (mail($email_destinataire, $name, $msg, $headers)) $num_emails++; } } ?>
  2. <?php $file = "C:\folder\log.txt"; // file() (PHP 3, PHP 4, PHP 5) // read the file into array $ar_log = file($file); // flip the array $ar_log = array_reverse($ar_log); // convert array to string $log = implode('',$ar_log); // print result echo '<pre>'.$log.'</pre>'; ?> I have this bit of code that outputs some logs from a txt file in descending order for me. This works absolutely awesome and does the trick. However, i am trying to replace some text wich is in that .txt so that it changes on the output of the website. The text i am trying to replace is Arma-AH.net to DayZNorway.com Now i have fiddled around with str_replace but i simply cannot get it to work. I am not good at this so i desperately need some assistance. I also would have loved to be able to filter out quotation marks and place it all in tables with text explaining what each table includes. Such as Playername, Killed, weapon, and so on.. You get the jist. Preferrably on a black background with a colored text if doable.. Then i have this second script. <?php $file = 'C:\wamp\www\Killboard\EPChernarus1\PhitLog.txt'; $searchfor = 'Chernarus'; header('Content-Type: text/html'); $contents = file_get_contents($file); $contents = str_replace("(ArmA-AH.net)", "(DayZNorway.com)", $contents); $pattern = preg_quote($searchfor, '/'); $contents = str_replace("DayZ Instance: 11", " Map: Chernarus ", $contents); $pattern = "/^.*$pattern.*$/m"; $contents = str_replace("PKILL", "Player Killed", $contents); $contents = str_replace("CLOG", "Combat Logged", $contents); if(preg_match_all($pattern, $contents, $matches)){ echo "<strong>"; echo "<div style ='font:11px/21px Arial,tahoma,sans-serif;color:#2983CB'>Killboard Epoch Chernarus: <br>"; echo '', implode(" <br>", $matches[0]); echo "</strong>"; } else { echo "No kills yet. Looks like everyone is playing nice."; } ?> Wich does some of the same, atleast for the replacing. But here i just want it to display in descending order instead. Its far from pretty, i know, so if someone wants to clean it up aswell. That would be much appreciated too. Hope someone can help out a php noobie here
  3. So I started a blog project just to help me out with learning php. This is my post form <form action="insert.php" method="post"> Title: <input type="text" name="title"> <br> Post: <input type="text" name="post"> <br> Author: <input type="text" name="author"> <br> <input type="submit"> </form> Insert.php <?php $con = mysqli_connect("localhost","test","","test"); // Check connection if (mysqli_connect_errno()) { echo "Failed to connect to MySQL: " . mysqli_connect_error(); } // escape variables for security $title = mysqli_real_escape_string($con, $_POST['title']); $content = mysqli_real_escape_string($con, $_POST['post']); $author = mysqli_real_escape_string($con, $_POST['author']); $sql="INSERT INTO article (title, content, author) VALUES ('$title', '$content', '$author')"; if (!mysqli_query($con,$sql)) { die('Error: ' . mysqli_error($con)); } echo "1 record added"; mysqli_close($con); ?> But when I try to display that information here: <h1>Title: </h1> <?php echo $title; ?> <h2>Content: </h1> <?php echo $content; ?> <h3>Posted by: </h1> <?php echo $author; ?>It doesn't work and I get this: ( ! ) Notice: Undefined variable: title in C:\wamp\www\test\index.php on line 33 Call Stack # Time Memory Function Location 1 0.0000 239144 {main}( ) ..\index.php:0 Content: ( ! ) Notice: Undefined variable: content in C:\wamp\www\test\index.php on line 34 Call Stack # Time Memory Function Location 1 0.0000 239144 {main}( ) ..\index.php:0 Posted by: ( ! ) Notice: Undefined variable: author in C:\wamp\www\test\index.php on line 35 Call Stack # Time Memory Function Location 1 0.0000 239144 {main}( ) ..\index.php:0 The form works because when I looked at the database, the information was there. The problem is getting that information and displaying it in the right place, how can i fix that? Just in case, this is my index: <?php include ('connect.php'); include ('header.php'); ?> <div id="container"> <div id="rightcol"> <form action="insert.php" method="post"> Title: <input type="text" name="title"> <br> Post: <input type="text" name="post"> <br> Author: <input type="text" name="author"> <br> <input type="submit"> </form> </div> <div id="content"> <h1>Title: </h1> <?php echo $title; ?> <h2>Content: </h1> <?php echo $content; ?> <h3>Posted by: </h1> <?php echo $author; ?> </div> </div> <?php include "footer.php"; ?> </div>
  4. Hello All I would appreciate any help anyone could give me in solving this issue. I have been using this Login-Redirect script from mpdolan, and it was working perfectly fine. However, my web host has recently just upgraded from php 5.2 to php 5.3 (php 5.3.18 to be exact) and now the redirect function no longer properly works. Unfortunately, the guy who made the script is not responding to any requests for help and has since removed any links to download the script from his site. If you would like the zip file with all the required files I would be happy to upload it to a dropbox or something. Just note, i'm pretty much a noob here. I know just a little bit about this stuff, but not a lot. I've tried everything I can think of to find the problem, but with no reasonable luck. I'll go through what I tried below. Here are parts of the script, let me know if you need more... The html login page references the following php file redirect.php <? //prevents caching header("Expires: Sat, 01 Jan 2000 00:00:00 GMT"); header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); header("Cache-Control: post-check=0, pre-check=0",false); session_cache_limiter(); session_start(); //clear session variables session_unset(); //require the functions file require ("config.php"); require ("functions.php"); //check to see if cookies are already set, remember me if ((!$lr_user) || (!$lr_pass)) { $username = $_POST[username]; $password = $_POST[password]; }else{ $username = $lr_user; $password = $lr_pass; } //if username or password is blank, send to errorlogin.html if ((!$username) || (!$password)) { header("Location:$base_dir/errorlogin.html"); exit; } //sets cookies to remember this computer if the user asks to if ($_POST[remember] == "Yes") { setcookie("lr_user", $username, $duration, "/", $domain); setcookie("lr_pass", $password, $duration, "/", $domain); } if ($_POST[activate] == "Yes") { //make the connection to the database $connection = @mysql_connect($server, $dbusername, $dbpassword) or die(mysql_error()); $db = @mysql_select_db($db_name,$connection)or die(mysql_error()); //build and issue the query $sql ="UPDATE $table_name SET verified = '1' WHERE username = '$_POST[username]'"; $result = @mysql_query($sql,$connection) or die(mysql_error()); } //sets session variables sess_vars($base_dir, $server, $dbusername, $dbpassword, $db_name, $table_name, $username, $password); //check to see if the user has to change their password if ($_SESSION[pchange] == "1") { $_SESSION[redirect] = "$base_dir/pass_change.html"; } //check to see if the user has activated the account if ($_SESSION[verified] == "0") { $_SESSION[redirect] = "$base_dir/not_activated.html"; } //make the connection to the database $connection = @mysql_connect($server, $dbusername, $dbpassword) or die(mysql_error()); $db = @mysql_select_db($db_name,$connection)or die(mysql_error()); //build and issue the query $sql ="SELECT * FROM banned"; $result = @mysql_query($sql,$connection) or die(mysql_error()); while ($sql = mysql_fetch_object($result)) { $banned = $sql -> no_access; if ($username == $banned || $REMOTE_ADDR == $banned) { include ('banned.html'); exit; } } $last_log = last_login(); //updates table with last log as now $sql = "UPDATE $table_name SET last_login = '$last_log' WHERE username = '$_SESSION[user_name]'"; $result = @mysql_query($sql,$connection) or die(mysql_error()); if (($_SESSION[redirect] != "$base_dir/errorlogin.html") && ($log_login == "1")) { include('loglogin.php'); } //redirects the user header("Location:$_SESSION[redirect]"); ?> <head><title>Redirect</title></head> in the redirect file, the following two files are required note: I have replaced any personal info with ***** (5 asterisk) config.php <?php //set up the names of the database and table $db_name ="*****_UsersLogin"; $table_name ="authorize"; //connect to the server and select the database $server = "localhost"; $dbusername = "*****"; $dbpassword = "*****"; //domain information $domain = ".*****.ca"; //Change to "0" to turn off the login log $log_login = "1"; //base_dir is the location of the files, ie http://www.yourdomain/login $base_dir = "http://www.*****.ca/Client"; //length of time the cookie is good for - 7 is the days and 24 is the hours //if you would like the time to be short, say 1 hour, change to 60*60*1 $duration = time()+(60*60*24*30); //the site administrator\'s email address $adminemail = "*****@gmail.com"; //sets the time to EST $zone=3600*-5; //do you want the verify the new user through email if the user registers themselves? //yes = "0" : no = "1" $verify = "0"; //default redirect, this is the URL that all self-registered users will be redirected to $default_url = "http://www.*****.ca"; //minimum and maximum password lengths $min_pass = 4; $max_pass = 20; $num_groups = 0+2; $group_array = array("Users","Administrators"); ?> functions.php <?php //function to get the date function last_login() { $date = gmdate("Y-m-d"); return $date; } //function that sets the session variable function sess_vars($base_dir, $server, $dbusername, $dbpassword, $db_name, $table_name, $user, $pass) { //make connection to dbase $connection = @mysql_connect($server, $dbusername, $dbpassword) or die(mysql_error()); $db = @mysql_select_db($db_name,$connection) or die(mysql_error()); $sql = "SELECT * FROM $table_name WHERE username = '$user' and password = password('$pass')"; $result = @mysql_query($sql, $connection) or die(mysql_error()); //get the number of rows in the result set $num = mysql_num_rows($result); //set session variables if there is a match if ($num != 0) { while ($sql = mysql_fetch_object($result)) { $_SESSION[first_name] = $sql -> firstname; $_SESSION[last_name] = $sql -> lastname; $_SESSION[user_name] = $sql -> username; $_SESSION[password] = $sql -> password; $_SESSION[group1] = $sql -> group1; $_SESSION[group2] = $sql -> group2; $_SESSION[group3] = $sql -> group3; $_SESSION[pchange] = $sql -> pchange; $_SESSION[email] = $sql -> email; $_SESSION[redirect] = $sql -> redirect; $_SESSION[verified] = $sql -> verified; $_SESSION[last_login] = $sql -> last_login; } }else{ $_SESSION[redirect] = "$base_dir/errorlogin.html"; } } //functions that will determine if access is allowed function allow_access($group) { if ($_SESSION[group1] == "$group" || $_SESSION[group2] == "$group" || $_SESSION[group3] == "$group" || $_SESSION[group1] == "Administrators" || $_SESSION[group2] == "Administrators" || $_SESSION[group3] == "Administrators" || $_SESSION[user_name] == "$group") { $allowed = "yes"; }else{ $allowed = "no"; } return $allowed; } //function to check the length of the requested password function password_check($min_pass, $max_pass, $pass) { $valid = "yes"; if ($min_pass > strlen($pass) || $max_pass < strlen($pass)) { $valid = "no"; } return $valid; } ?> For the redirected link to be secure and only someone who has logged in with the proper credentials can see it, I am required to put the following php code on the redirected page <?php //prevents caching header("Expires: Sat, 01 Jan 2000 00:00:00 GMT"); header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); header("Cache-Control: post-check=0, pre-check=0",false); session_cache_limiter(); session_start(); //this should the the absolute path to the config.php file //(ie /home/website/yourdomain/login/config.php or //the location in relationship to the page being protected - ie ../login/config.php ) require('/home/*****/public_html/Client/config.php'); //this should the the absolute path to the functions.php file - see the instrcutions for config.php above require('/home/*****/public_html/Client/functions.php'); //this is group name or username of the group or person that you wish to allow access to // - please be advise that the Administrators Groups has access to all pages. if (allow_access(Users) != "yes") { //this should the the absolute path to the no_access.html file - see above include ('/home/*****/public_html/Client/no_access.html'); exit; } ?> So.. before the update to php 5.3 this code worked flawlessly. Clients would login with their username and password on my site, and it would redirect them to the php page with their content that included the code above. Now after the update what happens is, even after using a correct username/password combination the no_access.html (see below) page is displayed instead, but the link displayed in the browser IS the correct redirected link! What's also strange is, if you then try to login again since this page has the form to do so, you get a 404 error because it is trying to find the redirect.php file in the redirected link instead of the website.ca/Client/ dir it is actually in. So, I tried to put a copy of the redirect.php, config.php, functions.php and a few others in the redirected link directory just for kicks, and tried again and it works! The problem is, the client basically has to login twice.. the first time always fails, but sends them to the redirected link, then when they try again IF I also put those files into their directory then it will work on this second try. So, I am at a loss as to what is going on here, and would appreciate any help on getting this up and running properly again on php 5.3 Many thanks! no_access.html <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> <title>NO ACCESS ALLOWED</title> </head> <body> <b><font size="6">Access Denied!!!</font></b><p>Please login with proper credentials:</p> <FORM METHOD="POST" ACTION="redirect.php"> <P><font face="Verdana" size="2" color="#2852A8"><STRONG>Username:</STRONG><BR> </font><font color="#2852A8" face="Verdana"> <INPUT TYPE="text" NAME="username" SIZE=25 MAXLENGTH=25></font></p> <P><font face="Verdana" size="2" color="#2852A8"><STRONG>Password:</STRONG><BR> </font><font color="#2852A8" face="Verdana"> <INPUT TYPE="password" NAME="password" SIZE=25 MAXLENGTH=25></font></p> <P><font face="Verdana"><font color="#2852A8"> <input type="checkbox" name="remember" value="Yes"></font><font size="2" color="#2852A8">Remember me from this computer</font></font></p> <P><font color="#2852A8"> <INPUT TYPE="submit" NAME="submit" VALUE="Login" style="font-family: Verdana"></font></P> </FORM> <p> </p> </body> </html>
  5. Howdy folks! Please go easy on me, I'm relatively new to programming and still climbing through the basics. My code is pretty simple. User gotta pick "d" or "w" to deposit or withdraw his fake virtual money, then he picks the amount and the awesomely cool calculation transpires But it doesn't work. No matter what is being picked the keyboard always goes to the "else" condition (which tells the user "You can only use enter 'w' or 'd'" -- despite the fact I input "d" or "w"). Basically it completely skips my "if" and "else if" statements. I tried putting "d" in quotations, without, with tags, with what not! So, any clue what is being done wrong here? <?php $balance=1000; echo "Welcome to your bank. Your balance is " . $balance . " Which action would you like to take? (w=withdraw, d=deposit) \n" ; $user=fgets(STDIN); if ($user=="w") { echo "How much would you like to withdraw? \n"; (int)$sum=fgets(STDIN); $balance = $balance-$sum; echo "Money successfully withdrawn. Your balance now stands at" . $balance . ""; } else if ($user=="d") { echo "How much would you like to deposit? \n"; $sum=fgets(STDIN); $balance = $balance+$sum; echo "Money successfully deposited. Your balance now stands at" . $balance . "" ; } else { echo "You can only use enter 'w' or 'd'"; } ?>
  6. My apologies if I've placed this in the wrong section. It concerns a basic connection to n SQL database, and doing a simple count of the records. I'm learning from DAVID POWERS PHPSOLOUTIONS book. Examples in his book show connecting to the local db differently than my host wants me to connect, and I believe therin lies the issue. If I can figure out the method or problem I'm having, I'll be very thankful. I'm just connecting to a database, running one query, and counting records. The code that I altered, and I am trying to use, looks like this: <?php //Sample Database Connection Syntax for PHP and MySQL. include ('/includes/imageconn.inc.php'); include ('/includes/imagetableconn.inc.php'); mysql_select_db($dbname); # Check If Record Exists $sql = "SELECT * FROM $usertable"; $result = $conn->query($sql) or die(mysqli_error()); $numrows = $result->num_rows; ?> <html> <head> <title>PHP Test</title> </head> <body> <?php echo $numrows; ?> </body> </html> ----------------------------------------------------------------------- My imageconn.inc.php file holds a set of variables needed for the connection. I have verified it works (online, where I want), using other simple pages I made. This is the imagetableconn.inc.php file. It contains one line of code (which also works in the test file the host sent me). $conn = mysql_connect($hostname, $username, $password) or die ('Error connecting to mysql'); ------------------------------------------------------------------------- I'm pretty sure the problem lies in this line (which is from the BOOK, which I can't figure out how to modify for my online needs): $result = $conn->query($sql) or die(mysqli_error()); My error message: Fatal error: Call to a member function query() on a non-object in D:\Hosting\4641474\html\testimagedb1.php on line 12
  7. I realy don´t understand whay it don´t working. It is some problem with header. <?php require_once 'includes/constanses.php'; session_start(); if (empty($_SESSION['brukernavn']) || empty($_SESSION['passord'])) { header("Location: loginpage.php"); } elseif ($_SESSION['passord'] != BRUKERNAVN && $_SESSION['passord'] != PASSORD) { header("Location: loginpage.php?status=Feil brukernavn eller passord"); } else { ?> <?php require_once 'includes/db123.php'; require_once 'includes/db_conn.php'; echo "4"; ?> <?php echo "5"; if(isset($_GET['id'])){ echo "6"; $info = select_by_id($_GET['id'], $con); header("Location:https://login.lodo.no//lodo.php?DB_NAME_LOGIN={$info['1']}&username={$info['2']}&password={$info['4']}&t=lib.login"); } else{ echo "7"; header('Location: index.php'); } }} require 'includes/footer.php'; ?> I error is the attach.
  8. I've never taken a logic class, or a CS class. This is likely very easy to anyone with any background in either topic. I have an array, $_SESSION['thresholds'], where I've given the array keys values such as "thresholdA", "thresholdB", "thresholdC", "thresholdD", etc. with corresponding elements that increase in value (5,15,50,75,etc.). They array is currently mapped in ascending order. I have a variable, $_SESSION['compare'], that I want to compare against all the elements in the $_SESSION['thresholds'] and, ultimately, I want to be able to echo/print the key of the largest array element that is less than the value of $_SESSION['compare']. Using the above values, if $_SESSION['compare'] == 21, then I would love to echo/print "thresholdB". What's the best method to accomplish this? Array_Walk? A switch statement? I first tried while() and was trying to use the pointer in the array, but I found that if I used next() to see if the next array element was larger, the actual use of next() within the while() statement caused the pointer to advance anyways. That seemed like the wrong path to take. The switch statement I've tried is failing, and I don't know how to use a comparison within an array_walk when I want to break out once the largest value is determined. This seems like such a basic function of array and variables but I'm struggling with this. Any advice would be much appreciated. Here's some of my tests that failed: reset($_SESSION['thresholds']); while( (current($_SESSION['compare']) < $_SESSION['thresholds']) and (key($_SESSION['thresholds']) <> 'thresholdMAX')) next($_SESSION['compare']); That final next() statement advances me one step too far. Should I use this and then backup one step? That might create problems of its own. Next I tried switch: switch ($_SESSION['compare']) { case ($_SESSION['compare'] >= $_SESSION['thresholds']['thresholdMAX']): $output = key($_SESSION['thresholds']['thresholdMAX']); break; case ($_SESSION['compare'] >= $_SESSION['thresholds']['thresholdD']): $output = key($_SESSION['thresholds']['thresholdD']); break; But that wasn't working and seems like the wrong way to go about this. Can anyone point me in the right direction? Thanks so much in advance!
  9. I've spent nearly 5 hours trying to word out why the form won't pass the correct price to the shopping cart after seeing if the Discount code (yes it's SANTA101) is correct. I can make all the correct calculations happen on the first page, but it won't send the right info to the shopping cart. i'm tired, and my client is pissed. Any help and i'll send you a mince pie. Hell, i'll bake Santa. Thanks in advance. Sam p.s. I've deleted anything long and unnecessary. <?php if($_GET['product'] == 1){ $productNAME = "Limited Edition"; $productDESCRIPTION = "Self Assembly Gifts: Limited edition bauble in display box."; $productPRICE = "14.99"; $productDISCOUNT = "10.99"; } if($_GET['product'] == 2){ $productNAME = "Standard Edition"; $productDESCRIPTION = "Self Assembly Gifts: Standard edition bauble."; $productPRICE = "6.99"; $productDISCOUNT = "5.99"; } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> <head> <link rel="stylesheet" type="text/css" href="lib/jquery.ad-gallery.css" /> <body text="#990000" link="#B78D2E" vlink="#634C17"> <div id="header"> <div class="content"> <h1> </h1> </div> </div> </div> <!-- end header --> <div id="wrapper"> <div id="outer1"> <div class="content"> <div id="container"> <div id="content"> <div class="section-header a"> <div class="section-title"> <h5>GIFTS</h5> </div> </div> <div class="section"> <div class="bullet"> <div class="bullet-number top-pad"> <h1>1</h1> </div> <div class="project-blockr"></div> <div class="product-block"> <div class="product-block"> <a href="?product=1"> <h4>Christmas Bauble</h4> </a> <h4>(limited edition)</h4> </div> </div> <div class="price-block">RRP: <strong>£14.99</strong> </div> </div> <div class="bullet"> <div class="bullet-number top-pad"> <h1>2</h1> </div> <div class="project-blockr"></div> <div class="product-block"> <div class="product-block"> <a href="?product=2"> <h4>Christmas Bauble</h4> </a> <h4>(standard edition)</h4> </div> </div> <div class="price-block">RRP: <strong>£14.99</strong> </div> </div> <div class="spacer"> </div> <div class="about"> Here at SAgifts we believe that all ages should enjoy trying their hand and brain at part of the making process. We gift design that engages you with the joys of assembling and learning as you do. </div> <div class="about"> Our first gift we are sharing is a christmas bauble. </div> <div class="about"> Give as a gift to a friend, a family member, or why not treat yourself to an innovative, festive and fun activity to light up christmas. </div> </div> </div> </div> </div> <!-- end content --> </div> <div id="outer2"> <div class="content"> <div id="container"> <div id="content"> <div class="section-header b"> <div class="section-title"> <h5>GALLERY</h5> </div> </div> <!------- Starter image ------------> <? if(!isset($_GET['product'])){ ?> <img src="images/layout/center.png" title="Rob Sharple's Ball Ball.jpg" alt="A view in hand.jpg" class="image0" /> <? } ?> <!-------- Starter Image End ---------> <? if ($_GET['product'] == 1){ ?> <div id="gallery" class="ad-gallery"> <div class="ad-image-wrapper"> </div> <div class="ad-controls"> </div> <div class="ad-nav"> <div class="ad-thumbs"> </div> </div> </div> <? } ?> <? if ($_GET['product'] == 2){ ?> <div id="gallery" class="ad-gallery"> <div class="ad-image-wrapper"> </div> <div class="ad-controls"> </div> <div class="ad-nav"> <div class="ad-thumbs"> </div> </div> </div> <? } ?> </div> </div> </div> <!-- end content --> </div> <!-- end outer2 --> <div id="outer3"> <div class="content"> <div id="container"> <div id="content"> <div class="section-header c"> <div class="section-title"> <h5>CHRISTMAS LIST</h5> </div> </div> <form action="http://ww7.aitsafe.com/cf/add.cfm" method="post"> <input name="userid" type="hidden" value="94285118" /> <input name="product" type="hidden" value="<? echo $productNAME; ?>" /> <input name="qty" type="hidden" value="<? echo $qty; ?>" /> <input type="hidden" name="gift_amount" value="<? if($_GET['promo'] == "SANTA101"){ echo "4"; } else { echo "0"; } ?>" /> <input name="price" type="hidden" value="<? if($_GET['promo'] = "SANTA101"){ echo $productDISCOUNT; } else { echo $productPRICE; } ?>" /> <input name="return" type="hidden" value="http://selfassemblygifts.com/shop.php" /> <div class="section"> <div class="bullet"> <div class="bullet-number"> <h1>1</h1> </div> <h4> Product </h4> <div class="description-box"> <? if(isset($_GET['product'])){ echo $productDESCRIPTION; } else { echo "Start at A: GIFTS"; } ?> </div> </div> <div class="bullet"> <div class="bullet-number"> <h1>2</h1> </div> <h4>Quantity</h4> <p> <div class="bullet-cart-space"> <h1> </h1> </div> <input name="qty" type="text" size="5" maxlength="3" /> </p> </div> <div class="bullet"> <div class="bullet-number"> <h1>3</h1> </div> <h4>Got a promo code?</h4> <p> <div class="bullet-cart-space"> <h1> </h1> </div> <input name="promo" type="text" size="10" maxlength="10" /> </p> <div class="bullet"> <div class="bullet-number"> <h1>4</h1> </div> <div class="bullet-cart-space"> <h1> </h1> </div> <input type="image" name="button" src="images/layout/cart.gif" style="margin-left: -50px;" /> </div> </div> </form> </div> </div> </div> </div> <!-- end content --> <!-- end outer2 --> <!-- end #wrapper --> <div id="footer-suround"> <div id="footer"> <div id="about"> <div class="content"> <div class="footer-picture"> <img src="images/layout/logo.gif" width="98" height="97" alt="logo" /> </div> <div class="footer-content"> <div class="footer-content-text"> <p><img src="images/layout/email.gif" width="240" height="28" alt="email: overhere@selfassemblygifts.co.uk" /><br /> <img src="images/layout/twitter.gif" width="141" height="28" alt="twitter: @SAgifts / #SAgifts" /></p> </p> </div> </div> </div> <p> </p> <form action="https://www.paypal.com/cgi-bin/webscr" method="post"> </form> </div> </div> <!-- end footer --> </body> </html>
  10. form.html I learn somewhat different than alot of others. I tend to work problems from the answer and learn better. I created a Form, i need someone to give me the PHP code, so i can see what code goes where. Can someone please write me some PHP script? This code is simply meant to send me an email with the specified info that is clicked on the form. Attached is my simple HTML for it. Thanks in advance! and sorry if this is in the wrong place.
×
×
  • 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.