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 824 results

  1. THE TASK: Receive an HTTP query from an external source. Use the information from the query to obtain information from a data base Insert the information from the database into a filler page. Load the filler into the host page in such away that both appear simultaneously. DILEMMA: I can perform all of these tasks individually, but I am at a loss as to how to move from Step 3 to Step 4. DISCUSSION: I am accustomed to loading a filler into a page that is already opened. And, I am accustomed to loading a page with information queried from a database. Although I am pretty sure that I can call a page and load it with a filler whose content is determined by the HTTP query (Steps 1 and 4). What I have not done and feel awkward about is filling the filler page with information from the database query before displaying both the page and the filler together. QUESTION: Any suggestions? Roddy
  2. Hello there all, I want to learn"How can i structure groups within a website? (groups like i mean-- admin ,moderators, helpers,users, etc-etc) ? " in context of PHP ... this site has the groups like this as i said, please someone provide me some concepts and ideas how i can implement this ?
  3. 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.
  4. Can someone give any suggestion how to check if a facebook address is valid when send by form input? I created a function checking the url address with get_headers at status code 302. This doesn't work when a facebook username doesn't exist, because it still gives true. How to solve this problem?
  5. $text = "i am a student of oxford university, and i love to tell everyone how much i have enjoyed my four years in school. the whole environment was really welcoming" . Actually, we have a database table called "text_word". So, i want a script that will search through the above text and check if any of those words from the above text does not exist in the "text_word" table, such word should be replaced by asterisks and store the replaced word into a separate column called "unmatched_word" in the same "text_word" table. let's assume the word "welcoming" was not existing in my database what i want to achieve is this. the text is parsed through the program INPUT: "i am a student of oxford university, and i love to tell everyone how much i have enjoyed my four years in school. the whole environment was really welcoming" . OUTPUT: "i am a student of oxford university, and i love to tell everyone how much i have enjoyed my four years in school. the whole environment was really ******" . Code Sample: foreach ($text as $word) { $select_word = $f->filterRecord("*", "parts_of_speech", "word", $word); $get_word = $f->show_data($select_word); $count_words = $f->numR($select_word); if ($count_words > 0) { $result[] = '<a href="word/?w='.$word.'">'.$word.'</a>'; } else { $result[] = "******"; } } Please i believe the code is not doing exactly what i want. If you have a better approach to how i can get the job done, i don't mind if you give me a fresh code snippet or script. I hope you understand what i'm trying to do now?
  6. my yii2 view/site/index is ok and my css is working there fine, however, other pages, for example view/about and view/login are just html without css and working terrible, what could be causing it? why my css is only working in view/index ?
  7. Dear programmers, I need to make website with 2 languages in Yii2 basic framework, however, I researched tons of times on google and other search engines and I could only find yii2 advanced internalisation. I need for basic mode, please if you have source codes for yii2 basic multiple languages or if you know any link or video tutorial about yii2 basic internalisation, please kindly share with me, I would be greatly appriciated. I am looking forward from hearing from you soon.
  8. Hello, I am wondering if someone can help me understand a website that I have stumbled across. I am fairly new to the world of web design and trying to make a site to display a personal portfolio. I love the layout of these pages: http://www.sophiehardydesign.com/ram . I'd love to know how it was made to see if it is within my ability to create a modified version of the same layout. I appreciate the help!
  9. Hi all, 1. I want to delete selected(checkbox) items from database(MySQL). Here I am not getting any error, but I couldn't do the delete function.2. Wants to play videos in website. Here videos storing into folder and also into database, but cannot playin website. I tried in many ways, but I couldn't. So, please help to make above mentioned functions workable. dashboard.php<form method="post" enctype="multipart/form-data"><input type="submit" name="delete" class="btn btn-primary" onclick="myFunction(id)" style="font-size: 15px; margin-left: 3em;" value="Delete" /></form><div><?php$query = mysqli_query($database, "SELECT * FROM video");while($row = mysqli_fetch_assoc($query)){$id = $row['id'];$name = $row['name'];$url = "../uploads";// $url = $row['url'];$fileextensionvalue= $row['fileextension'];echo "<span class='col-md-6'><div class='row'><div class='col-md-1'><label class='checkbox'><input style='margin-right:1em;' name='checkbox[<?php echo $id; ?>]' type='checkbox' id='checkbox[]' data-toggle='checkbox' /></label></div><div class='col-md-1'><a href='#' style='color:red;font-size:18px;'>$id</a></div><div class='col-md-10'><a href='#' style='color:red;font-size:18px;'>$name</a></div></div><center style='padding:25px;'><video width='320' preload='auto' controls><source src='$url' type='video/$fileextensionvalue;codecs='avc1.42E01E, mp4a.40.2, H.264, aac, FLAC, Opus, VP9, VP8, Vorbis''/></video></center></span>";}?></div><script type="text/javascript">function myFunction(id){var r=confirm("Are you sure to delete selected video/s ?");if(r==true){window.location.assign("deleteVideo.php?id=" + id);}}</script>deleteVideo.php<?phpinclude '../database/database.php';$sql = mysqli_query($database, "SELECT * FROM video WHERE id='$id'");if(empty($_POST['delete'])){Print '<script>alert("Please choose file/s to delete.");</script>';Print '<script>window.location.assign("dashboard.php");</script>';}else if(!empty($_POST['delete'])){foreach($_POST['checkbox'] as $id => $val){if($val=='checked'){$query=mysqli_query("DELETE FROM video WHERE id = '".$id."'");$result= mysqli_query($database, $query) or die("Invalid query");}}}?>
  10. I made a piece of code to check wheter a url page exists. This is a part of the get_headers routine I'm using: <?php // check with checkdnsrr // validate with FILTER_VALIDATE_URL /////////////////////////////////////////////////// // get_headers part $array = get_headers($url); var_dump($array); $string = $array[0]; if( strpos($string,"200") || strpos($string,"301") || strpos($string,"302") || strpos($string,"403") ) { var_dump($url); } else { echo '<br><br> this site is insecure<br>'; echo '<br> use http instead of https <br><br>'; } } ?> The problem is that some websites configure their server either http or https but this does not mean that there is page content. What can be used to determine if there is an index.php or an index.html or any alternative indexpage used? The things I'm considering are: file_exists, file_get_contents or glob() on the other hand var_dump($array) gives in several cases the parameter: Content Type. The value is txt/html . Can this be used to see if there is a page? What would you recommend and can you give an example how this is used?
  11. QUESTION: How does one read the expression Feed::ATOM in the brief block of code below? class ATOM extends Feed { /** * {@inheritdoc} */ public function __construct() { parent::__construct(Feed::ATOM); } }
  12. QUESTION: How does one read the expression Feed::ATOM in the brief block of code below? class ATOM extends Feed { /** * {@inheritdoc} */ public function __construct() { parent::__construct(Feed::ATOM); } }
  13. RECENT DISCOVERY: I recently discovered a handy PHP function called show_source( ) and would now like to apply it in a particular sort of way. GOAL: I would like to open a new tab in my current window that shows the source code of a page that I have opened in the window. DILEMMA: Since PHP operates before a page is opened I am a lot confused about how to make this happen. This is what I have accomplished so far. $( document ).ready(function() { console.log( "ready!" ); $('.show_src a').on('click', function(event) { event.preventDefault(); var address = $(this).attr('href'); window.open(address); ... }); }); <li class='show_src'>The <a href='./composer/php_rss_generator/RSSGenerator/ItemInterface.php' title='' target='_blank'>Interface</a></li> <li class='show_src'>The <a href='./composer/php_rss_generator/RSSGenerator/Item.php' title='' target='_blank'>Class</a></li> I have tried a variety of ways to replace the three dots above including .ajax( ) and window.write( ) but nothing seems to work. Any ideas? Roddy
  14. 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!";}?>
  15. 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,
  16. 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; } } ?>
  17. 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.
  18. 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?
  19. 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
  20. 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
  21. 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
  22. 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.
  23. 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>
  24. 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
  25. 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'; } ?>