Search the Community

Showing results for tags 'PHP'.



More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • W3Schools
    • General
    • Suggestions
    • Critiques
  • HTML Forums
    • HTML/XHTML
    • CSS
  • Browser Scripting
    • JavaScript
    • VBScript
  • Server Scripting
    • Web Servers
    • Version Control
    • SQL
    • ASP
    • PHP
    • .NET
    • ColdFusion
    • Java/JSP/J2EE
    • CGI
  • XML Forums
    • XML
    • XSLT/XSL-FO
    • Schema
    • Web Services
  • Multimedia
    • Multimedia
    • FLASH

Calendars

  • Community Calendar

Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Languages

Found 812 results

  1. Here I can upload videos successfully into database and videos are saving in appropriate folder named "uploaded". As I mentioned in question, once after uploading the video, if I refresh the browser the previously uploaded video is going saving in my database. Another question is, if I click on the video(displayed name in myvideo.php), video is not going to display instead I am getting "Object Not Found" error. I request you people to give me solutions to solve these problems. Below I am posting my code: myvideo.php: <div class="content"><div class="card"><div class="header" id="stand-fix" style="border-bottom: 1px solid #E1E1E1;"><?phpif(isset($_POST['submit'])){// $conn = mysqli_connect("localhost", "root", "", "videos") or die(mysqli_error());$name = (isset($_FILES['file']['name']) ? $_FILES['file']['name'] : '');$temp = (isset($_FILES['file']['tmp_name']) ? $_FILES['file']['tmp_name'] : '');move_uploaded_file($temp, "uploaded/".$name);$url = "http://localhost/xampp/htdocs/VS/uploaded/$name";mysqli_query($database, "INSERT INTO video VALUE ('','$name','$url')");}?><form action="myvideo.php" method="post" enctype="multipart/form-data"><div class="row"><div class="col-md-7"><h4 class="title">My Videos</h4></div><div class="col-md-3"><input type="file" name="file" class="btn btn-primary" style="font-size: 15px;"><br /></div><div class="col-md-2"><input type="submit" name="submit" class="btn btn-primary pull-right" style="font-size: 15px;" value="Upload"></div></div></form><?phpif(isset($_POST['submit'])){echo '<script language="javascript">';echo 'alert("Your video has been successfully uploaded.")';echo "window.location.href='dashboard.php'";echo '</script>';}?><hr width="50%"></div><div class="content" style="height: 30em; direction: ltr; overflow: auto;"><div class="row" style="margin-left:4em;" style="direction: rtl;"><?php$database = mysqli_connect("localhost", "root", "", "videos") or die(mysqli_error());$query = mysqli_query($database, "SELECT * FROM video");while($row=mysqli_fetch_assoc($query)){$id = $row['id'];$name = $row['name'];$url = $row['url'];echo "<p style='margin:0.5em;'><a href='watch.php?id=$id' style='color:red;'>$id&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$name</a></p><br />";echo "<embed src='.$id.$url.'><video width='200' height='200' controls></video></embed>";}?></div></div></div></div> watch.php<?php$conn = mysqli_connect("localhost", "root", "", "videos") or die(mysqli_error());if(isset($_GET['id'])){$id = $_GET['id'];$query = mysqli_query($conn, "SELECT * FROM video WHERE id='$id'");while($row=mysqli_fetch_assoc($query)){$name = $row['name'];$url = $row['url'];}echo "<p style='font-size:20px;'><center>You are watching ".$name."</center></p><br /><embed src='.$url.'><video width='600' height='400' controls></video></embed>";}else{echo "Error!";}?>
  2. BACKGROUND: I have recently created the content of an automatically generated podcast using a PHP Class that I found on a webpage found https://www.phpclasses.org/package/2957-PHP-Generate-RSS-2-0-feeds.html. Unfortunately, when I attempt to display the generated feed all that is displayed are the values of the input variables, or alternatively nothing (see (below)depending on the method of display. In short, the desired formatting -- the reason that I downloaded the PHP Class -- is missing. The page that creates the above result is a text file with a .php extension and a header( ) function. $rss_feed->encoding = 'UTF-8'; $rss_feed->version = '2.0'; $rss_feed->createFeed($rss_channel); header('Content-Type: text/xml; $rss_channel = the object that combines the formatting with the values of the input variables and their respective objects. The Class is relatively straight-forward and easily customized, but for two lines that I do not understand and could well be preventing the display of the XML code, if not properly configured. Interestingly, whether they are commented out or left in tact, they have no affect on what is displayed. $selfUrl = (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != 'on' ? 'http://' : 'https://'); $selfUrl .= $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF']; When I run the .php file the following message appears at the top of the completed page. Still nothing below the message appears. Also, I do not know the source of this message. it does not appear to come from the .php document. Now, I have not constructed a style-sheet for the Feed page, but I hardly see how this could stop the feed from appearingl Please advise.
  3. Hi All, I am new to php and I don't about following error. So I request you to give me solution for this and also please explain something about this error. Here I am working on User's profile page. I able to fetch data and displaying in profile's form, but data is not updating and I got the following error when I clicked for "Updation". " Uncaught Error: Call to a member function bindParam() on boolean in C:\xampp\htdocs\VS\components\update-profile.php:16 Stack trace: #0 {main} thrown in C:\xampp\htdocs\VS\components\update-profile.php on line 16 " And my code is: <?php include '../_database/database.php'; ini_set("display_errors",1); session_start(); $msg=""; $temp=(isset($_SESSION['Username']) ? $_SESSION['Username'] : ''); $id=(isset($_SESSION['Id']) ? $_SESSION['Id'] : ''); if($_SERVER["REQUEST_METHOD"] == "POST") { $username = $_POST['Username']; $email = $_POST['Email']; $employee = $_POST['EmployeeID']; $designation = $_POST['Designation']; $password = $_POST['Password']; $sql=$database->prepare("update set Username=:name,Email=:email,EmployeeID=:employee,Designation=:designation,Password=:password where Id='$id'"); $sql->bindParam(':Username',$name,PDO::PARAM_STR, 50); $sql->bindParam(':Email',$email,PDO::PARAM_STR, 50); $sql->bindParam(':EmployeeID',$employee,PDO::PARAM_INT, 11); $sql->bindParam(':Designation',$designation,PDO::PARAM_STR, 50); $sql->bindParam(':Password',$password,PDO::PARAM_STR, 50); if($sql->execute()){ echo "<font face='Verdana' size='2' color=green>You have successfully updated your profile<br></font>"; } else{ print_r($sql->errorInfo()); $msg=" <font face='Verdana' size='2' color=red>There is some problem in updating your profile. Please contact site admin<br></font>"; } } ?> If this is wrong kindly give me a solution. Thank You,
  4. BACKGROUND: Please find below a portion of a PHP class used to create an RSS feed. Included are only the constructor function and the function used to create the actual document. All other functions have been omitted so as to focus on the question at hand. My reason for posting this code is to better understand the proper way to create a class. As you can readily see from the __construct( ) function of this class each new instance of the class requires six parameter values. Although the author lists these parameters at the beginning of the class definition, he comments them out, rather than initializing them. QUESTION: Is this standard practice? What is to be gained by not declaring them outside of the __construct( ) function? It appears to create an unnecessary repetitious use of the pseudo $this variable. <?php /** * rss_feed (simple rss 2.0 feed creator php class) * * @author Christos Pontikis http://pontikis.net * @copyright Christos Pontikis * @license MIT http://opensource.org/licenses/MIT * @version 0.1.0 (28 July 2013) * */ class rss_feed { /** * Constructor * * @param array $a_db database settings * @param string $xmlns XML namespace * @param array $a_channel channel properties * @param string $site_url the URL of your site * @param string $site_name the name of your site * @param bool $full_feed flag for full feed (all topic content) */ public function __construct($a_db, $xmlns, $a_channel, $site_url, $site_name, $full_feed = false) { // initialize $this->db_settings = $a_db; $this->xmlns = ($xmlns ? ' ' . $xmlns : ''); $this->channel_properties = $a_channel; $this->site_url = $site_url; $this->site_name = $site_name; $this->full_feed = $full_feed; } /** * Generate RSS 2.0 feed * * @return string RSS 2.0 xml */ public function create_feed() { $xml = '<?xml version="1.0" encoding="utf-8"?>' . "\n"; $xml .= '<rss version="2.0"' . $this->xmlns . '>' . "\n"; // channel required properties $xml .= '<channel>' . "\n"; $xml .= '<title>' . $this->channel_properties["title"] . '</title>' . "\n"; $xml .= '<link>' . $this->channel_properties["link"] . '</link>' . "\n"; $xml .= '<description>' . $this->channel_properties["description"] . '</description>' . "\n"; // channel optional properties if(array_key_exists("language", $this->channel_properties)) { $xml .= '<language>' . $this->channel_properties["language"] . '</language>' . "\n"; } if(array_key_exists("image_title", $this->channel_properties)) { $xml .= '<image>' . "\n"; $xml .= '<title>' . $this->channel_properties["image_title"] . '</title>' . "\n"; $xml .= '<link>' . $this->channel_properties["image_link"] . '</link>' . "\n"; $xml .= '<url>' . $this->channel_properties["image_url"] . '</url>' . "\n"; $xml .= '</image>' . "\n"; } // get RSS channel items $now = date("YmdHis"); // get current time // configure appropriately to your environment $rss_items = $this->get_feed_items($now); foreach($rss_items as $rss_item) { $xml .= '<item>' . "\n"; $xml .= '<title>' . $rss_item['title'] . '</title>' . "\n"; $xml .= '<link>' . $rss_item['link'] . '</link>' . "\n"; $xml .= '<description>' . $rss_item['description'] . '</description>' . "\n"; $xml .= '<pubDate>' . $rss_item['pubDate'] . '</pubDate>' . "\n"; $xml .= '<category>' . $rss_item['category'] . '</category>' . "\n"; $xml .= '<source>' . $rss_item['source'] . '</source>' . "\n"; if($this->full_feed) { $xml .= '<content:encoded>' . $rss_item['content'] . '</content:encoded>' . "\n"; } $xml .= '</item>' . "\n"; } $xml .= '</channel>'; $xml .= '</rss>'; return $xml; } } ?>
  5. Apologies if this has been covered. I use W3CSS for websites which is great then incorporate PHP to give the sites structure and cut down coding. Are there any plans to set up instructions on this combination? Thank you.
  6. I was trying to make a blog with YII2, my framework is confusing to call data from database. For example when I call "username" from "user" table, <?= DetailView::widget([ 'model' => $model, 'attributes' => [ 'user.fullname', --->> Yii2 is thinking that this is a category and not a user table 'title', 'description', 'content:html', 'count_view', 'status', 'created_at', ], ]) ?> I am getting this error: -->> unknown property: app\models\Category::fullname please could you help me to solve this issue, where I did make a mistake?
  7. I would like to preserve the keys to the associative input array ($varnames) and replace the values with those of $_POST. This function replaces the both the keys and values and returns an index array with the $_POST values. function replace_value($a, $b) { $a = $b; return $a; }; $varnames = array_map(replace_value, $varnames, $_POST); print_r($varnames); Any suggestions? Roddy
  8. QUESTION: When a variable is passed via a super global from one file to another what happens to the variable that is passed? Where is it stored? What is its half-life? Roddy
  9. I have been given a .asp file that needs converting into PHP, the only issue i am having is with the mass update fields. <%@ Language=VBScript %> <% if Request.QueryString("Home") = Request.QueryString("Away") Then %> <% Response.Redirect("same.asp") %> <%End If%> <% if Request.QueryString("HomeGoal") > Request.QueryString("AwayGoal") Then%> <% Home = Request.QueryString("Home") away = Request.QuerySTring("Away") Goal = Request.QueryString("HomeGoal") GoalIn = Request.QueryString("AwayGoal") Set objConn = Server.CreateObject("ADODB.Connection") ConnStr = "DRIVER={MySQL ODBC 3.51 Driver};SERVER=localhost;DATABASE=databse;UID=username;PWD=password!;" objconn.Open(ConnStr) objConn.Execute "UPDATE teams SET Victories = Victories + 1 WHERE Team='" & Home & "'" objConn.Execute "UPDATE teams SET Points = Points + 3 WHERE Team='" & Home & "'" objConn.Execute "UPDATE teams SET Played = Played + 1 WHERE Team='" & Home & "'" objConn.Execute "UPDATE teams SET Made = Made + '" & Goal & "' WHERE Team='" & Home & "'" objConn.Execute "UPDATE teams SET Let = Let + '" & GoalIn & "' WHERE Team='" & Home & "'" objConn.Execute "UPDATE teams SET Defeats = Defeats + 1 WHERE Team='" & Away & "'" objConn.Execute "UPDATE teams SET Played = Played + 1 WHERE Team='" & Away & "'" objConn.Execute "UPDATE teams SET Made = Made + '" & GoalIn & "' WHERE Team='" & Away & "'" objConn.Execute "UPDATE teams SET Let = Let + '" & Goal & "' WHERE Team='" & Away & "'" objConn.Close Set objConn= Nothing %> <%End if%> <% if Request.QueryString("HomeGoal") < Request.QueryString("AwayGoal") Then%> <% Home = Request.QueryString("Home") Away = Request.QuerySTring("Away") Goal = Request.QueryString("HomeGoal") GoalIn = Request.QueryString("AwayGoal") Set objConn = Server.CreateObject("ADODB.Connection") ConnStr = "DRIVER={MySQL ODBC 3.51 Driver};SERVER=localhost;DATABASE=databse;UID=username;PWD=password!;" objconn.Open(ConnStr) objConn.Execute "UPDATE teams SET Defeats = Defeats + 1 WHERE Team='" & Home & "'" objConn.Execute "UPDATE teams SET Played = Played + 1 WHERE Team='" & Home & "'" objConn.Execute "UPDATE teams SET Made = Made + '" & Goal & "' WHERE Team='" & Home & "'" objConn.Execute "UPDATE teams SET Let = Let + '" & GoalIn & "' WHERE Team='" & Home & "'" objConn.Execute "UPDATE teams SET Victories = Victories + 1 WHERE Team='" & Away & "'" objConn.Execute "UPDATE teams SET Points = Points + 3 WHERE Team='" & Away & "'" objConn.Execute "UPDATE teams SET Played = Played + 1 WHERE Team='" & Away & "'" objConn.Execute "UPDATE teams SET Made = Made + '" & GoalIn & "' WHERE Team='" & Away & "'" objConn.Execute "UPDATE teams SET Let = Let + '" & Goal & "' WHERE Team='" & Away & "'" objConn.Close Set objConn= Nothing %> <%End if%> <% if Request.QueryString("HomeGoal") = Request.QueryString("AwayGoal") Then%> <% Home = Request.QueryString("Home") Away = Request.QueryString("Away") Goal = Request.QueryString("HomeGoal") GoalIn = Request.QueryString("AwayGoal") Set objConn = Server.CreateObject("ADODB.Connection") ConnStr = "DRIVER={MySQL ODBC 3.51 Driver};SERVER=localhost;databse=fifa2;UID=username;PWD=password!;" objconn.Open(ConnStr) objConn.Execute "UPDATE teams SET Draws = Draws + 1 WHERE Team='" & Home & "'" objConn.Execute "UPDATE teams SET Points = Points + 1 WHERE Team='" & Home & "'" objConn.Execute "UPDATE teams SET Played = Played + 1 WHERE Team='" & Home & "'" objConn.Execute "UPDATE teams SET Made = Made + '" & Goal & "' WHERE Team='" & Home & "'" objConn.Execute "UPDATE teams SET Let = Let + '" & GoalIn & "' WHERE Team='" & Home & "'" objConn.Execute "UPDATE teams SET Draws = Draws + 1 WHERE Team='" & Away & "'" objConn.Execute "UPDATE teams SET Points = Points + 1 WHERE Team='" & Away & "'" objConn.Execute "UPDATE teams SET Played = Played + 1 WHERE Team='" & Away & "'" objConn.Execute "UPDATE teams SET Made = Made + '" & GoalIn & "' WHERE Team='" & Away & "'" objConn.Execute "UPDATE teams SET Let = Let + '" & Goal & "' WHERE Team='" & Away & "'" objConn.Close Set objConn= Nothing %> <%End if%> <% Home = Request.QueryString("Home") %> <% Away = Request.QueryString("Away") %> <% HomeGoal = Request.QueryString("HomeGoal") %> <% AwayGoal = Request.QueryString("AwayGoal") %> <head> <title>Game: <%=Home%> against <%=Away%> - Result updated...</title> <H3>Result submitted</H3><HR> <CENTER><B><%=Home%> - <%=HomeGoal%> - <%=AwayGoal%> - <%=Away%></CENTER><BR> <HR> <% if HomeGoal = AwayGoal Then %> <CENTER>The game ended as a draw!</CENTER> <%End If%> <% if HomeGoal > AwayGoal Then %> <CENTER><%=Home%> won against <%=Away%> !</CENTER> <%End If%> <% if HomeGoal < AwayGoal Then %> <CENTER><%=Away%> won against <%=Home%> !</CENTER> <%End If%> </b> <input type="button" value="Back" OnClick="top.location='results.asp'"> result_process.asp
  10. Hi everyone, I need a little help with trying to figure out what I need to do. I am writing an IF statement that allowed only certain users can see. So what I am trying to do, in my DB i have it created that if you are going to have certain access, the value in the DB is set to '1' for true. What I need help with is seeing how I can write and IF statement that reads that value and allows the user to see it. This is the current code I have: <?php if (isset($_SESSION['id'])) { echo "Welcome"; } else { echo "You not logged in or don't have access."; } ?> With this code, anyone that logs in will be able to see it. What I want is another line of code that allows those with the value of '1' in the DB to see it. I have tried many different ways of seeing if I can get it to work but it never does. It either always returned the value TRUE and reads the code or the value is FALSE; even if when I am login, the value turn FALSE. So if anyone can give me just a quick moment of their time, that would be great. NOTE: My DB Connection is in a header.
  11. undefined index grade in line 108 <?php if (!isset($_SESSION)) { session_start(); } IF(isset($_SESSION['username'])) ECHO "WELL COME ".$_SESSION['username']."<BR>"; else IF(isset($_SESSION['Name'])) if(isset($_POST['button'])) { $correct=0; $wrong=0; $sum=0; $grade=''; $total_q=@$_POST['total']; for($i=1;$i<=$total_q;$i++) { $con = mysql_connect("localhost","root"); mysql_select_db("oes", $con); $sql = "SELECT * from question_page where question='".@$_POST['q'.$i]."' and Answer='".@$_POST['ans'.$i]."'";// where schedule.status='active' $result = mysql_query($sql,$con); $result1 = mysql_fetch_array($result); if(mysql_num_rows($result)) $correct++; $wrong=$_POST['total']-$correct; $sum=($correct*10)/$_POST['total']; //echo "question of page:".@$_POST['q'.$i]." <br>answer of user ".@$_POST['ans'.$i]."<br>"; //echo "question of db:".$result1['question']." <br>answer of db ".$result1['Answer']."<br><br>"; if($sum>=9 && $sum<=10) { $grade="A+"; } else if($sum>=8.5 && $sum<9) { $grade="A"; } else if($sum>=8 && $sum<8.5) { $grade="A-"; } else if($sum>=7.5 && $sum<8) { $grade="B+"; } else if($sum>=7 && $sum<7.5) { $grade="B"; } else if($sum>=6.5 && $sum<7) { $grade="B-"; } else if($sum>=6 && $sum<6.5) { $grade="C+"; } else if($sum>=5 && $sum<6) { $grade="C"; } else if($sum>=4.5 && $sum<5) { $grade="C-"; } else if($sum>=4 && $sum<4.5) { $grade="D"; } else if($sum>=3.5 && $sum<4) { $grade="Fx"; } else if($sum>=0 && $sum<3.5) { $grade="F"; } } echo "total number of question ".$_POST['total']."<br>"; echo "total number of correct answer".$correct."<br>"; echo "total number of wrong answer".$wrong."<br>"; echo "total number of Marks:".$sum."<br>"; echo "your grade is:".$grade."<br>"; } else { header('location:Exam.php'); } ?> <script src="SpryAssets/SpryValidationTextField.js" type="text/javascript"></script> <link href="SpryAssets/SpryValidationTextField.css" rel="stylesheet" type="text/css"> <style type="text/css"> </style> <div id="right"> <?php $cnct=mysql_connect("localhost","root","")or die("not connected"); $qry=mysql_select_db("oes") or die("not connected"); $crsnm=mysql_query("select course_name from schedule where schedule_id='".$_GET['Id']."'"); $data=mysql_fetch_array($crsnm); $a=$_SESSION['ID']; $b=$_SESSION['Name']; $c=$_POST['total']; $g=$_POST['grade']; $con=mysql_connect("localhost","root","")or die("not connected"); $query=mysql_select_db("oes") or die("note selected"); $res="insert into result values('$a','$b','$correct','$wrong','$sum','$c', '$g' ,'yes','".$data['course_name']."')"; $sql=mysql_query($res) or die(mysql_error()); if(!$sql) { echo"not inserted ".mysql_error()."<br>"; } else { echo"inserted"."<br>"."<br>"; } ?> <?php $a=$_SESSION['ID']; $b=$_SESSION['Name']; $c=$_POST['total']; $d=$_POST['grade']; $con=mysql_connect("localhost","root","")or die("not connected"); $query=mysql_select_db("oes") or die("note selected"); $sql=mysql_query("insert into result values('$a','$b','$correct','$wrong','$sum','$c','$d')") or die(mysql_error()); if(!$sql) { echo"not inserted ".mysql_error()."<br>"; } else { echo"inserted"."<br>"."<br>"; } mysql_close($con); ?> <br/--> <div align="center"> </div> <td bgcolor="#c24122">&nbsp;</td> </tr> </table> </div> </div> and it calculate the result from exam.php which are below as follows: <?php if (!isset($_SESSION)) { session_start(); } IF(isset($_SESSION['username'])) ECHO "WELL COME ".$_SESSION['username']."<BR>"; else IF(isset($_SESSION['Name'])) //ECHO "WELL COME ".$_SESSION['Name']."<BR>"; //ECHO "YOUR ID IS ".$_SESSION['ID']."<BR>"; $var=$_SESSION['ID']; //echo$_SESSION['Name']; ?> <?php $sql=mysql_connect("localhost","root","")or die("not connected"); mysql_select_db("oes"); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <link href="style.css" rel="stylesheet" type="text/css" /> <title></title> <style type="text/css"> <!-- .style1 { color: #FFFFFF; font-weight: bold; } --> </style> </head> <body> <div id="container"> <?php include "Header.php"; ?> <div id="content"> <div id="left"> <rights> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <?php /* echo $_SESSION['co1']."<br>"; echo $_SESSION['co2']."<br>"; echo $_SESSION['co3']; */ $con=mysql_connect("localhost","root","")or die('not selected'); mysql_select_db("oes",$con)or die('not selected'); $sql="select * from schedule"; $query=mysql_query($sql); while($row = mysql_fetch_array($query)) { $sub= $coname=$row['course_name']; //echo $sub."<br>"; } $gu=$var; //echo $gu; mysql_close($con); $con=mysql_connect("localhost","root","")or die("not connected"); $query=mysql_select_db("oes",$con)or die("not selected"); $sql= "select Stud_ID from result where Stud_ID='".$gu."' AND status='yes'"; $result = mysql_query($sql); //$date= $row_Recordsetd['exam_date']; //if(!mysql_num_rows($result)) //if((!mysql_num_rows($result))) { ?> <html> <head> <title></title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> </head> <body> <?php $dateFormat = "d F Y -- g:i a"; $targetDate = time() + (1*60);//Change the 25 to however many minutes you want to countdown $actualDate = time(); $secondsDiff = $targetDate - $actualDate; $remainingDay = floor($secondsDiff/60/60/24); $remainingHour = floor(($secondsDiff-($remainingDay*60*60*24))/60/60); $remainingMinutes = floor(($secondsDiff-($remainingDay*60*60*24)-($remainingHour*60*60))/60); $remainingSeconds = floor(($secondsDiff-($remainingDay*60*60*24)-($remainingHour*60*60))-($remainingMinutes*60)); $actualDateDisplay = date($dateFormat,$actualDate); $targetDateDisplay = date($dateFormat,$targetDate); ?> <?php $con1 = mysql_connect("localhost","root"); mysql_select_db("oes", $con1); $Recordsetd = mysql_query("SELECT exam_time From schedule where schedule_id='".@$_GET['Id']."'") or die(mysql_error()); $row_Recordsetd = mysql_fetch_array($Recordsetd); //$ex_tih=$row_Recordsetd['exam_time'][strlen($row_Recordsetd['exam_time'])-8].$row_Recordsetd['exam_time'][strlen($row_Recordsetd['exam_time'])-7]; //$ex_tim=$row_Recordsetd['exam_time'][strlen($row_Recordsetd['exam_time'])-5].$row_Recordsetd['exam_time'][strlen($row_Recordsetd['exam_time'])-4]; $ex_tis=$row_Recordsetd['exam_time'][strlen($row_Recordsetd['exam_time'])-2].$row_Recordsetd['exam_time'][strlen($row_Recordsetd['exam_time'])-1]; ?> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Quiz System</title> <script type="text/javascript"> var days = <?php echo $remainingDay; ?> var hours = <?php echo $ex_tih; ?> var minutes = <?php echo $ex_tim; ?> var seconds = <?php echo $ex_tis; ?> function setCountDown () { seconds--; if (seconds < 0){ minutes--; seconds = 60 } if (minutes < 0) { hours--; minutes = 59 } if (hours < 0) { days--; hours = 23 } document.getElementById("remain").innerHTML = days+" days, "+hours+" hours, "+minutes+" minutes, "+seconds+" seconds"; SD=window.setTimeout( "setCountDown()", 1000 ); if (minutes == '00' && seconds == '00') { //seconds = "00"; window.clearTimeout(SD); { //document.getElementById('file2').style.visibility = 'hidden'; window.location = "check.php"; //document.getElementById('OptionA').disabled = true; } //window.alert("Time is up. Press OK to continue."); // change timeout message as required //$('input').disabled = true; } } </script> </head> <body onload="setCountDown();"> <!--Start Time: <!?php echo $actualDateDisplay; ?><br /> End Time:<!?php echo $targetDateDisplay; ?><br /--> <h2><b> <div id="remain"><?php echo "$remainingDay days, $remainingHour hours, $remainingMinutes minutes, $remainingSeconds seconds";?></div></b></h2> <h1> <!?php echo $_SESSION['Name'];?></h1> <p> <form id="form2" name="form2" method="post" action="point.php?Id=<?php if(isset($_GET['Id']))echo $_GET['Id'];?>"> <!--input type="text" name="course" value="<!?php if(isset($_GET['Id']))echo $_GET['Id'];?--> <?php $SID=@$_GET['Id']; // Establish Connection with Database $con1 = mysql_connect("localhost","root"); // Select Database mysql_select_db("oes", $con1); //$query_Recordsetd = ; $Recordsetd = mysql_query("SELECT course_name From schedule where schedule_id='".@$_GET['Id']."'") or die(mysql_error()); $row_Recordsetd = mysql_fetch_array($Recordsetd); $con = mysql_connect("localhost","root"); mysql_select_db("oes", $con); $sql = "SELECT * from question_page where course_name='".$row_Recordsetd[0]."'";// where schedule.status='active' $result = mysql_query($sql,$con); $i=1; while($row = mysql_fetch_array($result)) { $Id=$row['exam_id']; $Question=$row['question']; $OptionA=$row['Option1']; $OptionB=$row['Option2']; $OptionC=$row['Option3']; $OptionD=$row['Option4']; //echo $Id; ?> </p> <?php if($Id=='mult') { echo' <td colspan="2"><table width="100%" height="64" border="0" cellpadding="0" cellspacing="0" bordercolor="#A6BF79" say true or fales> <tr> <td height="32" width="50%">('.$i.')<input type="text" style="width:1000%;background:none;border:hidden;" readonly name="q'.$i.'" value="'.$Question.'"></td> </tr> <tr> <td height="32" width="50%"><input type="radio" name="ans'.$i.'" value="A" id="OptionA" /> '.$OptionA.'</td> <td width="50%"><input type="radio" name="ans'.$i.'" value="B" id="OptionC" /> '.$OptionC.'</td> </tr> <tr> <td height="32" width="50%"><input type="radio" name="ans'.$i.'" value="C" id="OptionB" /> '. $OptionB.'</td> <td width="50%"><input type="radio" name="ans'.$i.'" value="D" id="OptionD" /> '.$OptionD.'</td> </tr> </table></td>'; } if($Id=='T/F') { echo '<tr> <td>('.$i.')</td><td height="36" colspan="2" bgcolor="#85A157"><span class="style1"></span> <tr>say True or False</tr> <input type="text" name="ans'.$i.'" style="margin-left:4px;width:25%;background-color:white;border:none;" value=""></td> <td><input type="text" style="width:auto;background:none;border:hidden;" readonly name="q'.$i.'" value="'.$Question.'"></td> </tr>'; } if($Id=='Filling'){ echo '<tr> <td>('.$i.')</td><td height="36" colspan="2" bgcolor="#85A157"><span class="style1"></span> <tr> Falling the space</tr> <input type="text" name="ans'.$i.'" style="margin-left:4px;width:25%;background-color:white;border:none;" value=""></td> <td><input type="text" style="width:auto;background:none;border:hidden;" readonly name="q'.$i.'" value="'.$Question.'"></td> </tr>'; } ?> <p> <?php $i=$i+1; } ?> </p> <p align="center"> </p> <div align="center"> <?php // Retrieve Number of records returned $records = mysql_num_rows($result); if($records!=0) { ?> <input type="text" hidden name="total" value="<?php echo mysql_num_rows($result);?>"> <input type="submit" name="button" id="button" value="Submit" /> <?php } // Close the connection mysql_close($con); } /*elseif(!mysql_num_rows($result)) { echo 'not access the exam'; } elseif(mysql_num_rows($result)) { echo 'not aceess the exam'; } else { echo" not access the exam"; }*/ ?> </div> </form> <p>&nbsp;</p> <h1>&nbsp;</h1> </div> <div id="footerline"></div> <div id="footer">Copyright &copy; 2017 JJU Online Examination System.<br/> All rights reserved.&nbsp;</div> </div> </body> </html>
  12. how do i convert this <select name="willwin" id="willwin"> <?php if ($db->numrows() > 0){ while ($row = $db->fetch()) { ?> <option value=''></option> <option value="<?php echo $row["willwin"]; ?>"><?php echo $row["team1"]; ?></option> <option value="<?php echo $row["willlose"]; ?>"><?php echo $row["team2"]; ?></option> <?php } } ?> </select> <br/><br/> <label>Tag Bettor</label> <select name="sub_cat" id="sub_cat"></select> to look like this $TPL_team_list = '<select name="willwin" class="form-control">' . "\n"; while ($row = $db->fetch()) { $TPL_team_list .= "\t" . ' <option value="' . $row[''] . '" ' . $selected . '>' . $row[''] . '</option> <option value="' . $row['team1'] . '" ' . $selected . '>' . $row['team1'] . '</option> <option value="' . $row['team2'] . '" ' . $selected . '>' . $row['team2'] . '</option> ' . "\n"; } $TPL_team_list .= '</select>' . "\n"; { $template->assign_block_vars('tag_bidder', array( 'TEAM' => $TPL_team_list, )); $i++; } i cant intergrate the above form (doesnt respond when place directly) in tpl unless converted
  13. Sorry people here I have asked this before, so its a bit embarassing to me. But .... I have the following question. Its about using a function inside an if condition. The thing is that when I make a function with 2 returns in this case $data and $alternative I receive them both back. I ask this for grasping how a function acts inside an if condition. So my question is: how does the php engine ‘reason’? Is the outcome of the return ONLY POSSIBLE if you return 1 value inside an if condition; so either true or false ? Example: <?php function valid_someting($data){ global $alternative; $count=''; $count = strlen($data); if ( ($count < 8 && ($count > 4) ) ) { $data = preg_replace('/[^a-zA-Z0-9!@#$%^&*()\-_=+{};:,<.>]/', '', $data ); // $data = ltrim($data); $data = rtrim($data); return $data; } $alternative = $data; return $alternative; } $data = 'abcdabcdabcd'; if (valid_someting($data)) { echo 'color input field green'; } else if ($alternative == TRUE) { echo 'color input field RED'; } ?>
  14. I have a security question. Though I have gone through OWASP docs I still need to place specific things in the right perspective. It is actually quite brief regarding examples. But regarding security, I have to admit that I dont know much about how hackers are operating. What I know is that javascript can be included and mysql injection can be done if you don't escape well. I have a piece of regex to allow as much characters as possible for password input. So also the <> the dot . and the semi-colon ; and the string. After forcing the user to use the right characters the password is encrypted with blowfish. Im actually not sure what happens, because if you encrypt malicious code, you can finally make it work again when you decrypt it. Probably its naive to ask online for hacking examples, because then you inform hackers. Maybe if you cant make up any risky situation, you can give a recommendation for which characters should be avoided for a password input. All input is encryted with password_verify / Blowfish. Then prepared OOP queries store the variable in the database. regex: $var='/[!@#$%^&*()\-_=+{};:,<.>]/'; then the preg_replace does: if(preg_match_all($var,$pas_inp, $o)<2) { echo '<br><br>input should contain at least 2 special chars , try again'; return FALSE; } How risky (in which possible situations) is the use of: < > . ; $ & regarding javascript, mysql injection and other possible hacks. (sorry it is a very open question, but to avoid problems I have to start somewhere)
  15. Hello! As you can see on my site there are three sections that include members with pictures. I need to only remove the middle one ( I have uploaded a picture that shows the exact section). I have located the point where the code is but I am not sure of what I should delete for I am afraid it might break the site. The website is www.gpseminars.gr and here is the part of the code I believe needs to be modified. <!--- ============ STAFFS =========== ------------> <div class="clear"></div> <div id="staff-box-item"> <h2 class="boxtoptitle" ><?php echo esc_attr(innovation_get_option('staffboxes-heading', 'WE ARE INSIDE')); ?></h2> <h4 class="boxtopdes" ><?php echo esc_textarea(innovation_get_option('staffboxes-heading-des', 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua')); ?></h4> <div id="grid-staff" class="main"> <?php foreach (range(1, 3 ) as $staffboxsnumber ) { ?> <div class="view-staff" > <div class="view-staff-name"> <h3><?php echo esc_attr(innovation_get_option('staffboxes-title' . $staffboxsnumber, 'OUR PROUD STAFF '. $staffboxsnumber )); ?></h3> <p><?php echo esc_attr(innovation_get_option('staffboxes-description' . $staffboxsnumber, 'Service Executive' )); ?></p> </div> <div class="view-staff-back social-link"> <a href="<?php echo esc_url(innovation_get_option('staffboxes-linka' .$staffboxsnumber, 'http://wordpress.org' )); ?>"></a> <a href="<?php echo esc_url(innovation_get_option('staffboxes-linkb' .$staffboxsnumber, 'http://wordpress.org' )); ?>"></a> <a href="<?php echo esc_url(innovation_get_option('staffboxes-linkc' .$staffboxsnumber, 'http://wordpress.org' )); ?>"></a> <a class="profile-link" href="<?php echo esc_url(innovation_get_option('staffboxes-link' . $staffboxsnumber, '#' )); ?>">&rarr;</a> </div> <img src="<?php echo esc_url(innovation_get_option('staffboxes-image' . $staffboxsnumber, get_template_directory_uri() . '/images/stf'. $staffboxsnumber . '.jpg')); ?>" /> </div> <?php } ?> </div> </div> <!--- ============ END OF STAFFS =========== ------------> THANK YOU IN ADVANCE.
  16. Hi,As the title said, i'm trying to update an SQL Server DB with php. From my code below, you can see that i call once a stored proc to get information who will be in a table. One of the row allow me (supposed to be)(the last row who is an input), to change an other one (row name GL). But with the button save, it seems like nothing change at all. I tried to make some log with console and i can see test1 and test2. So it seems like it can go throught but doesnt ajust anything. I really don't know anymore and i really need your help. Any ideas or help will be really really appreciate. More on that, i'm not sure if i do it well about sql injection... <?php if(isset($_POST["test"])) { $NewValue = $_POST["noGL" . $_POST["TLZno"]]; $TLZ = $_POST["TLZ"];?> <script> console.log ("test1"); </script> <?php $sql1 = "UpdateGL @CIE ='RAL', @TLZ='$TLZ', @NOGL='$NewValue'";?> <script> console.log ("test2"); </script> <?php } else { echo "Rien!"; } ?> <button class="btn btn-success btn-sm dropdown-toggle save" name='submit' id='submit' type="submit" value="Enregistrer"> <i class="fa fa-floppy-o fa-lg" aria-hidden="true"> Enregistrer</i> </button> <script> $(document).ready(function(){ $('.save').click(function(){ $('#GL_form').submit(); }); }); </script> </div><!-- Fin class pull-left--> <div class="panel panel-primary filterable"> <div class="panel-heading"> <h1 class="panel-title" style="font-weight:bold;">Liste des numéros de GL</h1> </div><!--Fin class panel-heading--> <div class="table-responsive"> <form id="GL_form" method="post" action="ListeGL.php"> <input type="hidden" id="test" name="test"/> <table id="employees" class="table table-highlight"> <thead> <tr class="filters" id="filters"> <th style="text-align: center;"># TLZ</th> <th style="text-align: left;">Description</th> <th style="text-align: center;">D/C</th> <th style="text-align: center;"># GL</th> <th style="text-align: left;">Nouveau # GL</th> </tr> </thead> <tbody> <?php $sql = "ListeGL"; $result = sqlsrv_query($conn, $sql); $row_count = sqlsrv_num_rows($result); while ($row = sqlsrv_fetch_array($result, SQLSRV_FETCH_ASSOC)) { //print_r( $row ); // debug code $couleur='black'; $font= 'normal'; $input="a"; if( strstr($row['HTML_CODE'], "BOLD()")){ $font= 'bold'; } if( strstr($row['HTML_CODE'], "BG()")){ $font2= '#D8D8D8'; } if( strstr($row['HTML_CODE'], "INPUT()")){ $input= 'input'; $font2= '#transparent'; } ?> <tr> <?php echo "<tr style=\"font-weight:$font; color:$couleur; background-color:$font2;\">"; ?> <td style="text-align: center;"><?php echo ($row['TLZno']); ?></td> <td style="text-align: left;"><?php echo ($row['TlzDescription']); ?></td> <td style="text-align: center;"><?php echo ($row['TlzType']); ?></td> <td style="text-align: center;"><?php echo ($row['noGL']); ?></td> <td style="font-weight: normal; text-align: left; color: #BDBDBD; "> <<?php echo $input . ' name="noGL' . $row['TLZno'] . '"'; ?> type="text" name="new" value="<?php echo ($row['noGL']); ?>" /> </td> </tr> <?php } ?> </tbody> </table> </form>
  17. BACKGROUND: I am tempted to write something like the following foreach ($non-matches as $key => $val) { echo '<script> $("#' . $key . '").append("<p style=' . '"color:red;">Complete this item!</p>);</script>)'; } QUESTION ONE: Under the assumption that the echo statement is correct would you recommend this as proper programming procedure? If not, please explain why and provide an alternative, more appropriate strategy that would achieve the same objective suggested by the use of a jQuery object ? QUESTION TWO: If it is proper programming procedure, please correct the echo statement so that it will achieve the following: $("#...").append("<p style='color:red;'>Complete this item!</p>"); EDIT: In order to assist you in your response, the PHP variable $non-matches contains a list of values for the id attributes of form input control tags that have been carefully selected through a prior PHP procedure. An alternative approach that is currently under consideration is to create a JSON object, assign it to a Javascript variable, and iterate the resulting object with jQuery.
  18. Hey guys, EDIT: I have been looking on the web to find a way to automatically download a pdf when a page opens, without user having to click a link. However, no solution found (at least which i can get to work...) Help is much appreciated!! Thanks guys!
  19. Hi, I would like to list all the items contained in a folder except for 2 or 3 specific ones. For example, let's say I've item 1, item 2, …, item 10 in /myFolder. I would like to list all the items of /myFolder but item 1, item 3 and item 4. I've come up with the following code which does the work but looks a bit awkward. <?php $dir = '/myFolder'; $filesDir = new FilesystemIterator($dir, FilesystemIterator::SKIP_DOTS); $fileName = ''; foreach ($filesDir as $file) { $fileName = $file->getBasename(); if ($fileName != 'item1' && $fileName != 'item3' && $fileName != 'item4') { echo $fileName.'<br>'; } } Is there a simple and more elegant way to accomplish this? Any help would be appreciated, thanks!
  20. BACKGROUND: The following routine takes a nested, associative array whose end-values are empty, extracts the keys of each non-recursive subarray, and properly echoes each. Rather, than returning the result as a newly constituted array, however, the function returns boolean true and displays the desired result in a non-useable form. Now, I have tried in vain to get the call-back function to produce an index-array of the echoed values that I can use outside the scope of the array_walk_recursive( ) function, but have failed miserably. QUESTION: How does one produce from the function a useable array that can be used outside of the function. $result = array_walk_recursive($insertion_vars, function($key, $value) { echo $value . '<br />'; });
  21. QUESTION: How does one manipulate jQuery in a $( document ).ready( function( ) {...}); with PHP? Is it even possible? BACKGROUND: I have created a form whose performance depends on a combination of both PHP and jQuery. Unfortunately, I cannot get the two sets of code to synchronize properly. A seasoned programmer would probably tell me to start over and use one or the other, but not both. Unfortunately, there are things that I know how to do in Javascript, but not in PHP, and vice versa. It is because of this that I have gotten myself into this mess.
  22. First off, thanks for letting me into the forums. Excuse a newbie but I have a question about fetching data from a database with PHP and AJAX. Let's say I wanted to fetch data from the database like in this example from W3Schools, but I had modified the dropdown to for example fetch all entries with last name Griffin, Swanson or Quagmire. I made the q variable take a string instead of an integer. $q = strval($_GET['q']); Now I want to expand the SQL query to also take another condition. "SELECT * FROM user WHERE LastName = '".$q."' AND Hometown = '".$q2."'"; I understand how to build the query and that I need to declare another variable (q2), but how do I modify the AJAX request? xmlhttp.open("GET","getuser.php?q="+str,true); Also, would I need to have a submit button now that there are two conditions? Thanks!
  23. Hello. A couple of weeks ago I concluded a couple of front end development courses and we only touched upon php coding. Since we didn't do much of it I used w3schools.com to learn some basics. I used the tutorial to make a contact form but I have a little problem. Currently the form is set (or rather was until I removed some code) to show anything that was entered in to the form on the site (basically like in this tutorial: https://www.w3schools.com/php/php_forms.asp). What I want the form to do is send the entered information to a predefined email address. But that's not all. It's going to be used on a singlepage website layout. I want the form to also show a prompt box that warns the user that either something went wrong or that the message was sent and reload the page back to the same position (I realise I need to use index#pageposition to do this but I don't know how to implement the link). Currently this only warns the user of what he did wrong (but not in a prompt box that something wrong happened) and reloads the page to the top. I'm a PHP noob (big noob), and I would appreciate if someone can help me out with this. Thank you :). <?php // define variables and set to empty values $nameErr = $emailErr = $genderErr = $websiteErr = ""; $name = $email = $gender = $comment = $website = ""; if ($_SERVER["REQUEST_METHOD"] == "POST") { if (empty($_POST["name"])) { $nameErr = "Vpiši ime!"; } else { $name = test_input($_POST["name"]); if (!preg_match("/^[a-zA-Z ]*$/",$name)) { $nameErr = "Dovoljene so samo črke in presledki!"; } } if (empty($_POST["email"])) { $emailErr = "Vpiši email naslov!"; } else { $email = test_input($_POST["email"]); if (!filter_var($email, FILTER_VALIDATE_EMAIL)) { $emailErr = "Vpišite veljaven email naslov!"; } } if (empty($_POST["subject"])) { $subjectErr = "Vpiši naslov sporočila!"; } else { $subject = test_input($_POST["subject"]); } if (empty($_POST["message"])) { $messageErr = "Vpiši sporočilo!"; } else { $message = test_input($_POST["message"]); } } function test_input($data) { $data = trim($data); $data = stripslashes($data); $data = htmlspecialchars($data); return $data; } ?> <!DOCTYPE html> <html> <link rel="stylesheet" href="style.css" type="text/css"> <link href="https://fonts.googleapis.com/css?family=Ubuntu" rel="stylesheet"> <meta name="kontakt"> <head> </head> <body> <div class="col-md-12"> <div class="form-area"> <form method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>"> <br style="clear:both"> <h3>Piši nam</h3> <div class="form-group"> <input type="text" class="form-control" name="name" placeholder="Ime"> <span class="error">* <?php echo $nameErr;?></span> </div> <div class="form-group"> <input type="text" class="form-control" name="email" placeholder="Email"> <span class="error">* <?php echo $emailErr;?></span> </div> <div class="form-group"> <input type="text" class="form-control" name="subject" placeholder="Naslov"> <span class="error">* <?php echo $subjectErr;?></span> </div> <div class="form-group"> <textarea class="form-control" type="textarea" placeholder="Sporočilo" name=message rows="8"></textarea> <span class="error">* <?php echo $messageErr;?></span> </div> <input type="submit" class="btn btn-primary" name="submit" value="Submit"> <!--<button type="button" name="submit" class="btn btn-primary pull-right" value="Submit">Pošlji</button>--> </form> </div> </div> </body>
  24. DISCLAIMER: After seeing what has been written on the internet on this subject I am loathe to start here, but have I any other choice? QUESTION: The PHP header(location: './sample.html'); is telling me that my headers have already been sent and is referring me back to the beginning of my PHP script. Can I buffer my way out of this mess? If so, Where to I start and stop the buffer? Where do I place the header( ) function? BACKGROUND: I have just spent several weeks setting up an email verification system and am putting on the decorative touches. Truly, I thought that I had almost reached the end; truly I fear now that I am far from finished. I hope that I am wrong.
  25. Hi Guys, I have a table that shows information and the status of that, being on or off. the on and off part is hard to notice and as it is the most valuable I was hoping to change it from simple text of on/off to a green/red circle. At the moment I am using a text input in a form for on/off. I have looked around and haven't found much related to this. I am having to replace the text input box with the radio button and if its clicked it will show green and if not it will show red. any suggestions on this? I will attach my code below: input form: <th>Repo Status: * <td><input type="text" name="status" value="<?php echo $status; ?>" /></td></tr> Displayed Table: echo '<td>' . $row['status'] .'</td>'; Thanks in advance