Jump to content

Search the Community

Showing results for tags 'variables'.

More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


  • 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


Last Updated

  • Start


Filter by number of...


  • Start





Website URL








Donation Link

Found 4 results

  1. My login script stores the user's login name as $_SESSION[ 'name'] on login. For some unapparent reason, i'm getting errors stating that $user and $priv are undefined variables, though I've attempted to define $user as being equal to $_SESSION['name'], using $user to look up the the user's privilege level (stored as the su column ) in the SQL table, and then where the result of the sql query is $priv which is then evaluated in an if statement. I can't seem to figure out why this might not be working. The code I'm using: <?php session_start(); function verify() { //verify that the user is logged in via the login page. Session_start has already been called. if (!isset($_SESSION['loggedin'])) { header('Location: /index.html'); exit; } //if user is logged in, we then lookup necessary privleges. $_SESSION['name'] was written with the login name upon login. Privleges // are written in db as a single-digit integer of of 0 for users, 1 for administrators, and 2 for special users. $user === $_SESSION['name']; //Connect to Databse $link = mysqli_connect("", "database user", "password", "database"); if (!$link) { echo "Error: Unable to connect to MySQL." . PHP_EOL; echo "Debugging errno: " . mysqli_connect_errno() . PHP_EOL; echo "Debugging error: " . mysqli_connect_error() . PHP_EOL; exit; } //SQL Statement to lookup privlege information. if ($result = mysqli_query($link, "SELECT su FROM accounts WHERE username = $user", MYSQLI_STORE_RESULT)) { //LOOP TO CYCLE THROUGH SQL RESULTS AND STORE Privlege information as vairable $priv. while ($row = $result->fetch_assoc()) { $priv === $row["su"]; } } // close SQL connection. mysqli_close($link); // Verify privleges and take action. Only a privlege of "1" is allowed to view this page. A privlege of "2" indicates special //accounts used in other scripts that have certain indermediate additional functions, but are not trusted administrators. if ($priv !== 1) { echo $_SESSION['name']; echo "you have privlege level of $priv"; echo "<br>"; echo 'Your account does not have the privleges necessary to view this page'; exit; } } verify(); ?>
  2. Hey! I want to create a website that can test your counting pace. I’ll make colored, square div that change color after 10 to 30 seconds when you hover over it, and then you’ll type down how long you think it took in a form to check if you’re right. My solution to do this is to create the PHP variable $time = rand(10,30), and in CSS get the div:hover transition-delay to be $time. Then, after the form, I need the same variable for if($_POST[timeguess] = $time) {echo “Correct!”}. I have no idea how to access the same variable in both the CSS and HTML, so I hope some of you can help me out! Thanks
  3. Help Please! I'm trying to pass variables in a URL and use them in a HTML email. When test1.php calls Test2.php, test2.php should send two HTML emails but nothing happens. I get this error for test2.php: [24-Feb-2016 16:20:42 UTC] PHP Parse error: syntax error, unexpected end of file in /home/my/public_html/test2.php on line 114 HTML - call test1.php <!DOCTYPE html> <html lang="en-US"> <head> <meta charset="utf8" /> <title>Testform.html</title> </head> <body bgcolor="tan" text ="black"> <form action="test1.php" method="POST" > <table> <tr> <th> ~ Test ~ <br /> </th> </tr> </table> <br /> <table> <tr> <td> * </td> <td> <strong> Required Fields </strong> </td> <tr> </table> <table> <tr> <td> <strong>Title: </strong> </td> <td> <select name="Title" size="1" > <option value="" selected>Please Choose</option> <option value="Mr."> Mr.</option> <option value="Ms."> Ms.</option> <option value="Mrs."> Mrs.</option> </select> </td> </tr> <tr> <td> <strong> First Name: </strong> </td> <td> <input type="text" name="Fname" maxlength="30" /> </td> </tr> <tr> <td> <strong> Last Name: </strong> </td> <td> <input type="text" name="Lname" maxlength="30" /> </td> </tr> <tr> <td> <strong> Suffix: </strong> </td> <td> <select name="Suffix" size="1"> <option value=""> Please Choose </option> <option value="Sr."> Sr.</option> <option value="Jr."> Jr.</option> <option value="III"> III</option> <option value="IV"> IV</option> <option value="V, "> V</option> </select> </td> </tr> <tr> <td> <strong> Address: </strong> </td> <td> <input type="text" name="Address" maxlength=40 /> </td> </tr> <tr> <td> <strong> City, State: </strong> </td> <td> <select name="CityState"> <option value=""> Please Choose </option> <option value="Hometown, CA"> Hometown, CA</option> <option value="My City, CA"> My City, CA</option> <option value="Beautiful, CA"> Beautiful, CA</option> </select> </td> </tr> <tr> <td> <strong> Zip Code: </strong> </font> </td> <td class="td2"> <input type="text" name="Zip" placeholder="99999" maxlength=10 /> </td> </tr> </table> <table> <tr> <th> <strong> Comments: </strong> </th> </tr> </table> <table> <tr> <td> <textarea rows="8" cols="60" name="Comments" wrap="hard"> </textarea> </td> </tr> </table> <table> <tr> <td> <input id="shiny" type="submit" value="Submit Form" /> </td> </tr> </table> </form> </body> </html> TEST1.PHP <?php //###Process testform.html //### Error Reporting error_reporting(E_ALL); //### Create Random Number srand((double) microtime() * 1000000); //### Define Variable(s) $random_number = rand(); $Test_number = "$random_number"; $Date = date("D d M Y - H:i:s "); $path = "/home/mypath/public_html/"; $myfile = "test1.txt"; $file = $path.$myfile; $fh = fopen($file, "a+") or die("Couldn't open $myfile"); //### Get Data From Form if ($_SERVER["REQUEST_METHOD"] === "POST") { if(isset($_POST["Title"])) { $Title = $_POST["Title"]; } if(isset($_POST["Fname"]) && !empty ($_POST["Fname"])) { $Fname = $_POST["Fname"]; if(preg_match("/[^a-zA-Z]*$/",$Fname)){ //### Upper Case First Letter of First Name $FnameUc = ucfirst($Fname); } else { echo"<strong>The First Name you entered is not valid.</strong>". PHP_EOL; echo "<br />\n"; exit; } } if(isset($_POST["Lname"]) && !empty ($_POST["Lname"])) { $Lname = $_POST["Lname"]; if(preg_match("/[^a-zA-Z]*$/",$Lname)){ //### Upper Case First Letter of Last Name $LnameUc = ucfirst($Lname); } else { echo"<strong>The Last Name you entered is not valid.</strong>". PHP_EOL; echo "<br />\n"; exit; } } if(isset($_POST["Suffix"]) && !empty ($_POST["Suffix"])) { $Suffix = $_POST["Suffix"]; } if(isset($_POST["Address"]) && !empty ($_POST["Address"])) { $Address = $_POST["Address"]; } else { echo "<br />\n"; } if(isset($_POST["CityState"]) && !empty ($_POST["CityState"])) { $CityState = $_POST["CityState"]; } else { echo " <strong> You didn't choose a City, State </strong> "; echo " <br /> "; die(); } if(isset($_POST["Zip"]) && !empty ($_POST["Zip"])) { $Zip = $_POST["Zip"]; } else { echo "<strong>You didn't enter Zip Code</strong>"; echo " <br /> "; die(); } if(isset($_POST["Email"]) && !empty ($_POST["Email"])) { $Email = trim($_POST["Email"]); //### check if e-mail address is well-formed if (!filter_var($Email, FILTER_VALIDATE_EMAIL)) { echo $Email . " <strong>is not a valid email address</strong>"; } } } //### Call Functions test1_1(); test1_2(); function test1_1(){ //### Write order to file appointment.txt global $Test_number, $Date, $Title, $FnameUc, $LnameUc, $Suffix, $Address, $CityState, $Zip, $Email, $Comments; if(is_readable($file)) { echo " "; } else { echo '<strong>The file is not readable</strong>\n\n'; die(); } if(is_writable($file)) { echo " "; } else { echo '<strong>The file is not writable</strong>'; die(); } //### Open file if(!$fh) { die("couldn't open file <i>$myFile</i>"); } else { $str = "\r\n"; $str.= "Test1 - $Test_number\r\n"; $str.= "Date: $Date\r\n"; $str.= "Name:\r\n"; $str.= "\t\t $Title $FnameUc $LnameUc $Suffix\r\n"; $str.= "Address:\r\n"; $str.= "\t\t $Address\r\n"; $str.= "City, State:\r\n"; $str.= "\t\t $CityState $Zip\r\n"; $str.= "\t\t $Email \r\n"; $str.= "Comments:\r\n"; $str.= "\t\t $Comments\r\n"; $str.= "\r\n"; $str.= "\r\n"; fwrite($fh, $str); } fclose($fh); } function test1_2() { //### Email (HTML) Someone global $Test_number, $Date, $Title, $FnameUc, $LnameUc, $Suffix, $Address, $CityState, $Zip, $Email, $Comments; //### Define Variables $mailto = $Email; $From = "me@mydomain.com"; $subject = "Test1"; //### Beginning of HTML message $message = <<<EOF <html> <body BGCOLOR="tan" TEXT="black"> <br><br> $Title $LnameUc, <br> We have received your Test. <br> The information you submitted is below: <br> <b>$Title $FnameUc $LnameUc $Suffix</b> <br> <b>$Address</b> <br> <b>$CityState $Zip</b> <br> <b>$Email</b> <br><br> Comments: <br> <b>$Comments</b> <br><br> Please click your <b><u>Confirm Email Address</u></b> ,below, to confirm your email address. <br><br> * * * * * * * * * * <a href="http://www.mydomain.com/test2.php?test_number= $Test_number&date=$Date&title=$Title&fname=$FnameUc&lname=$LnameUc&suffix=$Suffix&address=$Address&citystate= $CityState&zip=$Zip&email=$Email&comments=$Comments">Confirm Email Address - $Test_number</a> * * * * * * * * * * <br><br> </body> </html> EOF; //end of message $headers = "Mime-Version: 1.0" . "\r\n"; $headers .= "Content-type: text/html; charset=iso-8859-1" ."\r\n"; $headers .= "Sensitivity: Personal\r\n"; $headers .= "From:" .$From . "\r\n"; $headers .= "Reply To:". $From . "\r\n"; $headers .= "Return-Path:" .$From . "\r\n"; $headers.= "BCC: me@mydomain.net\r\n"; $headers .= "X-Priority: 1 (Highest)\r\n"; $headers .= "X-MSMail-Priority: High\r\n"; $headers .= "Importance: High\r\n"; //### now lets send the email if(mail($mailto, $subject, $message, $headers)) { echo "<b> <font color='green' size='+2'> Test1 sent.</font></b>"; } else { echo "<b> <font color='red' size='+2'>Test1 not sent.</b></font>"; } } ?> TEST2.PHP <?php //### Test2.php called by Test1.php //### Error Reporting error_reporting(E_ALL); //### Define varibles $Date = $_GET["date"]; $Appointment_number = $_GET["appointment_number"]; $Title = $_GET["title"]; $FnameUc = $_GET["fname"]; $LnameUc = $_GET["lname"]; $Suffix = $_GET["suffix"]; $Address = $_GET["address"]; $CityState = $_GET["citystate"]; $Zip = $_GET["zip"]; $Email = $_GET["email"]; $Comments = $_GET["comments"]; //### Call Function(s) test2_1(); test2_2(); //### HTML Email to Client function test2_1() { global $Date, $Test_number, $Title, $FnameUc, $LnameUc, $Suffix, $Address, $CityState, $Zip, $Email, $Comments; //### Define variables $mailto = $Email; $From = "me@mydomain.com"; $subject = "Test2 - ". $Test_number."\r\n"; //### Beginning of HTML message $message = <<<EOF <html> <body BGCOLOR="tan" TEXT="black"> <br><br> $Title $FnameUc $LnameUc $Suffix <br> Your email address <b><$mailto></b> is confirmed. <br><br> </body> </html> EOF; //### end of message $headers = "Mime-Version: 1.0\r\n"; $headers .= "Content-type: text/html; charset=iso-8859-1\r\n"; $headers .= "Sensitivity: Personal\r\n"; $headers .= "From: ".$From. "\r\n"; $headers .= "Reply-To: ".$From. "\r\n"; $headers .= "Return-Path: ".$From. "\r\n"; $headers .= "BCC: horacef@horacefranklinjr.net \r\n"; $headers .= "X-Priority: 1 (Highest)\r\n"; $headers .= "X-MSMail-Priority: High\r\n"; //### Now lets send the email if(mail($mailto, $subject, $message, $headers)) { echo "<b> <font color='green' size='+2'>Email address Confirmation sent to: ".$mailto."</font></b>"; echo "<br /> <br />"; } else { echo "<b> <font color='red' size='+2'>Email address Confirmation not sent.</font></b>"; echo "<br /> <br />"; } } //### HTML Email to Horace function test2_2() { global $Date, $Appointment_number, $Title, $FnameUc, $LnameUc, $Suffix, $Address, $CityState, $Zip, $Email, $Comments; //### Define variables $mailto = $Email; $From = "me@mydomain.com"; $subject = "Test2 - ". $Test_number."\n\n"; //### begin of HTML message $message = <<<EOF <html> <body BGCOLOR="tan" TEXT="black"> <br><br> You have received an Test, <b>that needs to be confirmed.</b> <br> Date Received: <b>$Date</b> <br><br> The information submitted is below: <br> <b>$Title $FnameUc $LnameUc $Suffix</b> <br> <b>$Address</b> <br> <b>$CityState $Zip</b> <br> <b>$mailto</b> <br><br> Comments: <br> <b>$Comments</b> <br><br> Please click the <b><u>Confirm Appointment</u></b> ,below, to confirm the Appointment Date and Time. <br><br> <a href="http://www.mydomain.com/Test3.php?date=$Date&test_number=$Test_number&title=$Title&fname=$FnameUc&lname=$LnameUc&suffix=$Suffix&address=$Address&citystate=$CityState&zip=$Zip&email=$Email&comments=$Comments"> Confirm Appointment - $Test_number</a> <br> </body> </html> EOF; //###end of message $headers = "Mime-Version: 1.0\r\n"; $headers .= "Content-type: text/html; charset=iso-8859-1\r\n"; $headers .= "Sensitivity: Personal\r\n"; $headers .= "From:" . $From . "\r\n"; $headers .= "Reply-To:" . $From . "\r\n"; $headers .= "Return-Path:" . $From . "\r\n"; $headers .= "BCC: me@mydomain.net\r\n"; $headers .= "X-Priority: 1 (Highest)\r\n"; $headers .= "X-MSMail-Priority: High\r\n"; //### Now lets send the email if(mail($mailto, $subject, $message, $headers)){ echo "<b> <font color='green' size='+2'> Confirm Appointment email sent to: ". $mailto."</b></font>"; echo "<br /> <br />"; } else { echo "<b> <font color='red' size='+2'> Confirm Appointment email not sent.</b></font>"; echo "<br /> <br />"; } ==> Line 114 }
  4. I am working on a item helper script. It consists of users selecting from multiple radio buttons for multiple items and updating them all at once. My question is the code below is used for each item the user has (used in "while ($stmt->fetch()){" statement") . With the way I have it set up, how will I make it so it updates the correct item for the right option? Also. how do I grab the bracket variable use_item[$id] ? <tr width=\"100%\"> <td> <p>$name</p> </td> <td> <center><input name=\"use_item[$id]\" type=\"radio\" id=\"use_item[$id]\" value=\"keep\"$check_keep></center> </td> <td width=\"50\"> <center><input name=\"use_item[$id]\" type=\"radio\" id=\"use_item[$id]\" value=\"stock\"$check_stock></center> </td> <td width=\"50\"> <center><input name=\"use_item[$id]\" type=\"radio\" id=\"use_item[$id]\" value=\"discard\"$check_discard></center> </td> <td width=\"50\"> <center><input name=\"use_item[$id]\" type=\"radio\" id=\"use_item[$id]\" value=\"donate\"$check_donate></center> </td> <td width=\"50\"> <center><input name=\"use_item[$id]\" type=\"radio\" id=\"use_item[$id]\" value=\"gallery\"$check_gallery></center> </td> <td width=\"50\"> <center><input name=\"use_item[$id]\" type=\"radio\" id=\"use_item[$id]\" value=\"gallery3\"$check_gallery3></center> </td> <td width=\"50\"> <center><input name=\"use_item[$id]\" type=\"radio\" id=\"use_item[$id]\" value=\"deposit\"$check_deposit></center> </td> </tr> The form takes them to the page that updates using the information they choose from above. A small snippet below. if(isset($_POST['submit'])){ $use = $_POST['use_item']; foreach($use as $use_item){ $item = $_POST['item_id']; /////// UPDATING MYSQLI INSERTED HERE ////////////////// } } Thank you for your time. Hopefully I posted enough information for your help.
  • 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.