PHP - Event Calendar Not Fully Functioning
Hi could anyone help me please.
Similar TutorialsThis topic has been moved to PHP Applications. http://www.phpfreaks.com/forums/index.php?topic=330163.0 Hi, I am using the backbone.js and full calendar script in my website. However, on clicking OK in the popup to add events, no action is taking place. Actually the event should be displayed on that specific date on clicking OK. the cancel button is working fine. I am using the link http://blog.shinetech.com/2011/08/05.../#comment-2245 Help me please. Thank you in advance howdy all I was wondering if anyone has any Basic Event calendar or a tutorial for a basic one.. I want to get a event calendar on my site but i want a basic one so i can tweak it to fit my likings. Thank you SilentHunter I got this Event Calendar Script off of a site and i like it but it reads from a Flat File Database and i would like it to read from a mysql database. Can someone help me set it up so it will read from a mysql database? here is the script where its calling from the flat file.. Code: [Select] $counterfilepath="calendar.txt"; if(file_exists($counterfilepath)) { $filehandle=fopen($counterfilepath,"r"); $pointer = 1; while(!feof($filehandle)) { $rowdata = fgets($filehandle); $day = floatval(substr($rowdata,3,2)); $eventlastpos = strpos($rowdata,'{')-1; if($eventlastpos<=0){$eventlastpos=255;} $event = rtrim(substr($rowdata,11,$eventlastpos-10)); $eventcaption = rtrim(substr($rowdata,$eventlastpos+2,strlen($rowdata))); $datalist = $this->eventsthismonth[$day]; $rowmonth = floatval(substr($rowdata,0,2)); $rowyear = floatval(substr($rowdata,6,4)); if($rowmonth==$month and $rowyear==$year) { if($eventcaption=="") {$eventcaption='';} else {$eventcaption='<b>'.$eventcaption.'</b><br>';} if($datalist=="") { $this->eventsthismonth[$day] = '<font name=Verdana size=1>'.$eventcaption.$event.'</font>'; } else { $this->eventsthismonth[$day] = $datalist.'<br><hr size=1 color=#E0E0E0><font name=Verdana size=1>'.$eventcaption.$event.'</font>'; } } $pointer = $pointer + 1; } fclose($filehandle); } and the flat file looks like this 07/13/2005|Technology Advisory Meeting{2:00pm I am workin on a event calendar and i ran into a problem.. it shows the calendar and the today's date and 1 event on each month but i want it to show all the events for each month. my problem is i can't figure out how to loop it so it will.. here is where im having trouble at.. Code: [Select] for ($i=0; $i<($maxday+$startday); $i++) { if(($i % 7) == 0 ){ echo "<tr>"; } if($i < $startday){ echo ("<td bgcolor='414141'> </td>"); } else { if (($i - $startday + 1) == $today && $currentmonth == $cMonth && $currentyear == $cYear){ echo ("<td bgcolor='FF0000'><center><font color='FFFFFF'>".($i - $startday + 1)."</font></center></td>"); } else { [color=red]// this is where i need it to loop[/color] if (($i - $startday + 1) == $eday && $eMonth == $cMonth && $eYear == $cYear){ echo ("<td bgcolor='0000FF'><center><a class='info' href='#'><font color='FFFFFF'>".($i - $startday + 1)."<span>".$event."<hr><br>".$event_des."</span></font></a></center></td>"); } else { echo ("<td bgcolor='595959'><center><font color='FFFFFF'>".($i - $startday + 1)."</font></center></td>"); } } if(($i % 7) == 6 ) { echo "</tr>\n"; } } } i marked where the loop needs to go in red.. currently i have the sql query right above it in my script but i tried putting it where i need the loop and i get a error in there or it duplicates the calender and sometimes the numbers. can some please help me? Thank you Outsider_Child HI im sorry if i post in a wrong thread im new here and im still young on PHP environment.. here is my problem hope someone can help me to solve this one here we goes, i got a project that i need to make a event calendar. where the members can see the whole month calendar then if they click the day with mark the page bring them to other page where they can see what event going to have on that day. then if admin was log.in the admin can do add,edit,delete by simply clicking on the calendar... tnx if u have time please send me an email or leave message here or reply on this forum thank you so much Hello guys I am developing my own system with event calendar but I stucked in the part where I should mark in the same way event which continue more than one day.What is my point - lets take for example google calendar, here you can see how the bar is purple for all 3 days marked for street cleaning : http://www.file-extensions.org/imgs/app-picture/6718/google-calendar.jpg Can you give me only an idea how I should proceed,what to use to achieve such result,what are my best options ? Thank you Good day! I created a webpages and i have a login page consist of Username and Department. And i encountered problem in adding event in my calendar. This is the flow of my webpage: First I have a separate table for the user and calendar. In my user table it has a Username, Department, and Permission. In the permission I put True or False, only one user i put True because i want that user is the one who permitted to add event or if she is login the add event link appear, but if other login the add even0t did not appear. This is my code in login: <?php session_start(); session_regenerate_id(); if($_SESSION['loggedin']){ //the user is already logged in, lets redirect them to the other page header("Location:company.php"); } //require_once 'conn.php'; $db_name="dspi"; mysql_connect("localhost", "root", "") or die("Cannot connect to server"); mysql_select_db("$db_name")or die("Cannot select DB"); $department = mysql_real_escape_string($_POST['department']); $username = mysql_real_escape_string($_POST['username']); $sql=mysql_query("SELECT `Department`, `Username` FROM `tbllogin` WHERE `Department` = '{$department}' AND Username = '{$username}'") or die(mysql_error()); $ct = mysql_num_rows($sql); if($ct == 1) { // im guessing this means that the user is valid. $_SESSION['loggedin'] = true; // now that the user is valid we change the session value. $row = mysql_fetch_assoc($sql); $_SESSION['username'] = $row['Username'] ; $_SESSION['department'] = $row['Department']; $Departments=array('Accounting', 'Engineering', 'Finishing_Goods', 'HRAD', 'MIS', 'Packaging_and_Design', 'Production', 'Purchasing_Logistic', 'QA_and_Technical', 'Supply_Chain'); if (in_array($row['Department'], $Departments)){ header ('Location:company.php'); }else{ echo "Incorrect Username or Department"; header ('Location:index.php'); } } ?> and this is my code in calendar page: <?php session_start(); $host = "localhost"; $username = ""; $password = ""; $dbCnx = @mysql_connect($host, $username, $password) or die('Could not Connect to the database'); $dbName = 'dspi'; mysql_select_db($dbName); ?> <html> <body> <script> function goLastMonth(month, year){ // If the month is January, decrement the year if(month == 1){ --year; month = 13; } document.location.href = '<?=$_SERVER['PHP_SELF'];?>?month='+(month-1)+'&year='+year; } //next function function goNextMonth(month, year){ // If the month is December, increment the year if(month == 12){ ++year; month = 0; } document.location.href = '<?=$_SERVER['PHP_SELF'];?>?month='+(month+1)+'&year='+year; } function remChars(txtControl, txtCount, intMaxLength) { if(txtControl.value.length > intMaxLength) txtControl.value = txtControl.value.substring(0, (intMaxLength-1)); else txtCount.value = intMaxLength - txtControl.value.length; } function checkFilled() { var filled = 0 var x = document.form1.calName.value; //x = x.replace(/^\s+/,""); // strip leading spaces if (x.length > 0) {filled ++} var y = document.form1.calDesc.value; //y = y.replace(/^s+/,""); // strip leading spaces if (y.length > 0) {filled ++} if (filled == 2) { document.getElementById("Submit").disabled = false; } else {document.getElementById("Submit").disabled = true} // in case a field is filled then erased } </script> <?php //$todaysDate = date("n/j/Y"); //echo $todaysDate; // Get values from query string $day = (isset($_GET["day"])) ? $_GET['day'] : ""; $month = (isset($_GET["month"])) ? $_GET['month'] : ""; $year = (isset($_GET["year"])) ? $_GET['year'] : ""; //comparaters for today's date //$todaysDate = date("n/j/Y"); //$sel = (isset($_GET["sel"])) ? $_GET['sel'] : ""; //$what = (isset($_GET["what"])) ? $_GET['what'] : ""; //$day = (!isset($day)) ? $day = date("j") : $day = ""; if(empty($day)){ $day = date("j"); } if(empty($month)){ $month = date("n"); } if(empty($year)){ $year = date("Y"); } //set up vars for calendar etc $currentTimeStamp = strtotime("$year-$month-$day"); $monthName = date("F", $currentTimeStamp); $numDays = date("t", $currentTimeStamp); $counter = 0; //$numEventsThisMonth = 0; //$hasEvent = false; //$todaysEvents = ""; //run a selec statement to hi-light the days function hiLightEvt($eMonth,$eDay,$eYear){ //$tDayName = date("l"); $todaysDate = date("n/j/Y"); $dateToCompare = $eMonth . '/' . $eDay . '/' . $eYear; if($todaysDate == $dateToCompare){ //$aClass = '<span>' . $tDayName . '</span>'; $aClass='class="today"'; }else{ //$dateToCompare = $eMonth . '/' . $eDay . '/' . $eYear; //echo $todaysDate; //return; $sql="select count(calDate) as eCount from calTbl where calDate = '" . $eMonth . '/' . $eDay . '/' . $eYear . "'"; //echo $sql; //return; $result = mysql_query($sql); while($row= mysql_fetch_array($result)){ if($row['eCount'] >=1){ $aClass = 'class="event"'; }elseif($row['eCount'] ==0){ $aClass ='class="normal"'; } } } return $aClass; } ?> <div id="Calendar_Event"> <table width="350" cellpadding="0" cellspacing="0"> <tr> <td width="50" colspan="1"> <input type="button" value=" < " onClick="goLastMonth(<?php echo $month . ", " . $year; ?>);"> </td> <td width="250" colspan="5"> <span class="title" style="color:#FFFFFF"><?php echo $monthName . " " . $year; ?></span><br> </td> <td width="50" colspan="1" align="right"> <input type="button" value=" > " onClick="goNextMonth(<?php echo $month . ", " . $year; ?>);"> </td> </tr> <tr> <th>M</td> <th>T</td> <th>W</td> <th>T</td> <th>F</td> <th>S</td> <th>S</td> </tr> <tr> <?php for($i = 1; $i < $numDays+1; $i++, $counter++){ $dateToCompare = $month . '/' . $i . '/' . $year; $timeStamp = strtotime("$year-$month-$i"); //echo $timeStamp . '<br/>'; if($i == 1){ // Workout when the first day of the month is $firstDay = date("N", $timeStamp); for($j = 1; $j < $firstDay; $j++, $counter++){ echo "<td> </td>"; } } if($counter % 7 == 0 ){ ?> </tr><tr> <?php } ?> <!--right here--><td width="50" <?=hiLightEvt($month,$i,$year);?>><a href="<?=$_SERVER['PHP_SELF'] . '?month='. $month . '&day=' . $i . '&year=' . $year;?>&v=1"><?=$i;?></a></td> <?php } ?> </table> </div> <div id="New_Event"> <?php if(isset($_GET['v'])){ if(isset($_POST['Submit'])){ $sql="insert into calTbl(calName,calDesc,calDate,calStamp) values('" . $_POST['calName'] ."','" . $_POST['calDesc'] . "','" . $_POST['calDate'] . "',now())"; mysql_query($sql); } $sql="select calName,calDesc, DATE_FORMAT(calStamp, '%a %b %e %Y') as calStamp from calTbl where calDate = '" . $month . '/' . $day . '/' . $year . "'"; //echo $sql; //return; $result = mysql_query($sql); $numRows = mysql_num_rows($result); $check=mysql_query("SELECT * FROM tbllogin WHERE Username='xxx' AND Department='HRAD' AND Permission='True'"); mysql_fetch_array($check); if($check['Username']=='xxx' && $check['Department']=='HRAD'){ $_SESSION['isallowed'] = $check['Permission']; //if (mysql_num_rows($check)>0){ ?> <a href="<?=$_SERVER['PHP_SELF'];?>?month=<?=$_GET['month'] . '&day=' . $_GET['day'] . '&year=' . $_GET['year'];?>&v=1&f=true">Add Even</a><a href="<?=$_SERVER['PHP_SELF'];?>?month=<?=$_GET['month'] . '&day=' . $_GET['day'] . '&year=' . $_GET['year'];?>&v=1&f=true">t</a><?php }else{ echo 'You cannot Add New Event'; }?> </div> <div id="Cal_Event"> <?php if(isset($_GET['f'])){ include 'calform.php'; } if($numRows == 0 ){ echo ''; }else{ //echo '<ul>'; echo '<h3>Event Listed</h3>'; while($row = mysql_fetch_array($result)){ ?> <h5><?=$row['calName'];?></h5> <?=$row['calDesc'];?><br/> Listed On: <?=$row['calStamp'];?> <?php } } } ?> </div> </body> </html> In that code when the user log is xxx and when she click a date she want to add event the appear is "You cannot Add Event". I hope somebody can help me.. Thank you in advance... This topic has been moved to Third Party PHP Scripts. http://www.phpfreaks.com/forums/index.php?topic=348839.0 my problem is if my local date is february 1 or march 30... if i press previous month i cant see the month of february, but if i press the change the local date to february 2 or march 29 i can see the month of february in my event calendar... what should i do to see the month of february even i set the local date in february 1 or march 30.... heres the code Code: [Select] if (isset($_GET['day'])){ $day = $_GET['day']; } else { $day = date("j"); } if(isset($_GET['month'])){ $month = $_GET['month']; } else { $month = date("n"); } if(isset($_GET['year'])){ $year = $_GET['year']; }else{ $year = date("Y"); } $currentTimeStamp = strtotime( "$day-$month-$year"); $monthName = date("F", $currentTimeStamp); $numDays = date("t", $currentTimeStamp); I have events added to mysql on my site and wish to them also to be added to my Google Calendar. Is this possible? Hi: I am working with a PHP Event Calendar. I am having trouble displaying the data the way I want to. If a person clicks on a number/date in the calendar (17, for example) the data will display fine below the calendar.\ However, I want to display only the Event Title ("calName") in the date box as a link, and allow the user to click the title to go to a new page to see the full Event info. I can not get any of the data to display and hope someone can tell me what I'm doing wrong. This is the code: Code: [Select] <script> function goLastMonth(month, year){ // If the month is January, decrement the year if(month == 1){ --year; month = 13; } document.location.href = '<?=$_SERVER['PHP_SELF'];?>?month='+(month-1)+'&year='+year; } //next function function goNextMonth(month, year){ // If the month is December, increment the year if(month == 12){ ++year; month = 0; } document.location.href = '<?=$_SERVER['PHP_SELF'];?>?month='+(month+1)+'&year='+year; } function remChars(txtControl, txtCount, intMaxLength) { if(txtControl.value.length > intMaxLength) txtControl.value = txtControl.value.substring(0, (intMaxLength-1)); else txtCount.value = intMaxLength - txtControl.value.length; } function checkFilled() { var filled = 0 var x = document.form1.calName.value; //x = x.replace(/^\s+/,""); // strip leading spaces if (x.length > 0) {filled ++} var y = document.form1.calDesc.value; //y = y.replace(/^s+/,""); // strip leading spaces if (y.length > 0) {filled ++} if (filled == 2) { document.getElementById("Submit").disabled = false; } else {document.getElementById("Submit").disabled = true} // in case a field is filled then erased } </script> ............... <p> <div id="legend"> <img src="images/Cal-Icon.jpg" style="padding: 0 15px 15px 0;" /> Today is: <? $today = date("F j, Y, g:i a"); echo " $today " ?> </div> <?php //$todaysDate = date("n/j/Y"); //echo $todaysDate; // Get values from query string $day = (isset($_GET["day"])) ? $_GET['day'] : ""; $month = (isset($_GET["month"])) ? $_GET['month'] : ""; $year = (isset($_GET["year"])) ? $_GET['year'] : ""; //comparaters for today's date //$todaysDate = date("n/j/Y"); //$sel = (isset($_GET["sel"])) ? $_GET['sel'] : ""; //$what = (isset($_GET["what"])) ? $_GET['what'] : ""; //$day = (!isset($day)) ? $day = date("j") : $day = ""; //comparaters for today's date //$todaysDate = date("n/j/Y"); //$sel = (isset($_GET["sel"])) ? $_GET['sel'] : ""; //$what = (isset($_GET["what"])) ? $_GET['what'] : ""; //$day = (!isset($day)) ? $day = date("j") : $day = ""; if(empty($day)){ $day = date("j"); } if(empty($month)){ $month = date("n"); } if(empty($year)){ $year = date("Y"); } //set up vars for calendar etc $currentTimeStamp = strtotime("$year-$month-$day"); $monthName = date("F", $currentTimeStamp); $numDays = date("t", $currentTimeStamp); $counter = 0; //$numEventsThisMonth = 0; //$hasEvent = false; //$todaysEvents = ""; //run a selec statement to hi-light the days function hiLightEvt($eMonth,$eDay,$eYear){ //$tDayName = date("l"); $todaysDate = date("n/j/Y"); $dateToCompare = $eMonth . '/' . $eDay . '/' . $eYear; if($todaysDate == $dateToCompare){ //$aClass = '<span>' . $tDayName . '</span>'; $aClass='class="today"'; }else{ //$dateToCompare = $eMonth . '/' . $eDay . '/' . $eYear; //echo $todaysDate; //return; $sql="select count(calDate) as eCount from calTbl where calDate = '" . $eMonth . '/' . $eDay . '/' . $eYear . "'"; //echo $sql; //return; $result = mysql_query($sql); while($row= mysql_fetch_array($result)){ if($row['eCount'] >=1){ $aClass = 'class="event"'; }elseif($row['eCount'] ==0){ $aClass ='class="normal"'; } } } return $aClass; } ?> <table width="900" cellpadding="0" cellspacing="0"> <tr> <td width="50" colspan="1"> <input type="button" value=" < " onClick="goLastMonth(<?php echo $month . ", " . $year; ?>);"> </td> <td width="250" colspan="5"> <span class="title"><?php echo $monthName . " " . $year; ?></span><br> </td> <td width="50" colspan="1" align="right"> <input type="button" value=" > " onClick="goNextMonth(<?php echo $month . ", " . $year; ?>);"> </td> </tr> <tr> <th>S</th> <th>M</th> <th>T</th> <th>W</th> <th>T</th> <th>F</th> <th class="lastOne">S</th> </tr> <tr> <?php for($i = 1; $i < $numDays+1; $i++, $counter++){ $dateToCompare = $month . '/' . $i . '/' . $year; $timeStamp = strtotime("$year-$month-$i"); //echo $timeStamp . '<br/>'; if($i == 1){ // Workout when the first day of the month is $firstDay = date("w", $timeStamp); for($j = 0; $j < $firstDay; $j++, $counter++){ echo "<td> </td>"; } } if($counter % 7 == 0){ ?> </tr><tr> <?php } ?> <!--right here--><td width="128" <?=hiLightEvt($month,$i,$year);?>><a href="<?=$_SERVER['PHP_SELF'] . '?month='. $month . '&day=' . $i . '&year=' . $year;?>&v=1"><?=$i;?></a> // TRYING TO DISPLAY CALENDAR EVENTS HERE <?php $sql="select calName,calDesc, DATE_FORMAT(calStamp, '%a %b %e %Y') as calStamp from calTbl where calDate = '" . $month . '/' . $day . '/' . $year . "'"; //echo $sql; //return; $result = mysql_query($sql); $numRows = mysql_num_rows($result); ?> <? while($row = mysql_fetch_array($result)){ ?> <div class="output"> <h5><?=$row['calName'];?></h5> <?=$row['calDesc'];?><br/> Listed On: <?=$row['calStamp'];?> </div> </td> </table> // END OF TRYING TO DISPLAY CALENDAR EVENTS HERE <?php } } ?> </p> Can anyone tell me what is wrong? Thanks! Hello ,
I am trying to display my planned events in calendar using full calendar json, jquery. But its not getting displayed, but its getting inserted. I am not very good at jquery or json. please somebody help me in this...
here is my code
in my calendar.php (display page)
<div class="span8"> <div class="w-box w-box-green"> <div class="w-box-header"></div> <div class="w-box-content"> <div id='calendar_json'></div> </div> <div class="w-box-footer"> <p class="f-text">JSON events fetched from a script</p> </div> </div> </div> </div>and in my calendar.js jsonEvents: function() { if($('#calendar_json').length) { $('#calendar_json').fullCalendar({ header: { left: 'month,agendaWeek,agendaDay', center: 'title', right: 'prev,next' }, buttonText: { prev: '<i class="icon-chevron-left icon-white cal_prev" />', next: '<i class="icon-chevron-right icon-white cal_next" />' }, editable: true, firstDay: 1, // 0 - Sunday, 1 - Monday events: "php_helpers/json-events.php", eventDrop: function(event, delta) { alert(event.title + ' was moved ' + delta + ' days\n' + '(should probably update your database)'); } }); }json-events.php include("connect.php"); $year = date('Y'); $month = date('m'); //$db=public_db_connect(); $year = date('Y'); $month = date('m'); $command = "SELECT * FROM planner"; $result = mysql_query($command) or die (mysql_error()); while ($row = mysql_fetch_array($result)) { echo "hi"; //$start = date("D, j M Y G:i:s T", strtotime($row['start'])); //$end = date("D, j M Y G:i:s T", strtotime($row['end_time'])); $start = date("Y-m-d", strtotime($row['from_time'])); //$start = "$year-$month-20"; $myid = $row['plan_id']; $eventsArray['plan_id'] = (int)trim($myid); //$eventsArray['title'] = $row['title']; $title = $row['company']; //$title = $row['title']; //echo $title; $eventsArray['company'] = $title; $eventsArray['from_time'] = $start; $eventsArray['to_time'] = $start; $eventsArray['url'] = "edit_calendar.php?calendarid=".$row['plan_id']; // $eventsArray['end'] = $end; // $eventsArray['allDay'] = false; $events[] = $eventsArray; } echo json_encode($events); Hi, Im trying to create a really simple password protected page that is fairly secure but when the user doesnt enter a password the wrong error is displayed. Can anyone see a problem? Also could someone please check that im properly compairing the hash password of 2135fa0dd7fb99d167b420b7ff34ec98 with what the user entered when its hashed? login.php <?php session_start(); ?> <?php $submit = $_POST['submit']; $password = md5($_POST['password']); if ($submit) { if ($password) { if ($password == '2135fa0dd7fb99d167b420b7ff34ec98') { $_SESSION['user'] = logged; header('Location: page.php'); } else { header('Location: index.php?id=1'); } } else { header('Location: index.php?id=2'); } } else { header('Location: index.php?id=1'); } ?> index.php <?php $id=$_REQUEST['id']; ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html lang="EN" dir="ltr" xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="content-type" content="text/xml; charset=utf-8" /> <title>Keys</title> <link rel = "stylesheet" type = "text/css" href = "css/layout.css" /> </head> <body> <div id="header"> <h1>Keys</h1> </div> <div id="secondheader"> </div> <div id="main"> <form method="POST" action="login.php"> Password: <input type="password" name="password" onfocus="selected(this)" onblur="notselected(this)"> <input type="submit" name="submit" value="Login"> </form> <br/> <?php if ($id==1) { echo "Invalid password. Please try again"; } elseif ($id==2) { echo "Please enter a password"; } ?> </div> <div id="footer"> </div> <div id="left"> </div> </body> </html> Thanks in advance. Is w3c a truce source to follow for any errors found on a website?
For eg. I have my links setup like this. < a href="record.php?id=4&user=smith"></a>
W3C is tell me to not use "&" symbol and that instead escape it as &
So what do I just replace & with & in all my links?
I have used the XAMPP installer to install php and MySQL locall on my computer. I also succeeded in setting the security for XAMPP pages, the MySQL admin user root and phpMyAdmin login. When I enter phpMyAdmin via the link in the XAMPP initial page I do however receive a red notification: phpMyAdmin configuration storage is not fully configured; some extensions are not activated. To find out click here. I have attached a screenshot showing three items which are not OK, shown in red. I looked up in the documentation, but could not find out. I hope someone can help. I don't even know if it is important to fix this problem. Regards, Erik Attached Files XAMPP2.jpg 41.08KB 0 downloads Problem: My code is not functioning at all on my form. I would like to see why? Scripting Info: Using PHP and MySQL Using offline Server for testing(XAMPP) Using default Server name and login.(localhost,root,[NO PASSWORD]) Database name is reh_temp Table within database is named users 1 Value in table "users" called users Goal: My form has 3 inputs. 2-Text and 1-Submit. The 1st text input has the name of id. And the 2nd input has the name of table. In the PHP/MySQL part the values are inputed as follows: The one with name of "id" gets put into the table users under the users value. The one with name of "table" creates a new table named after what the user inputs The rest of the script is just Character Length checks, Exsistance of value checks, Match check, ect. Here's the code: Code: [Select] <?php $connect1 = mysql_connect("localhost","root",""); if (!$connect) die('Could not connect to the database: ' . mysql_error()); $id = $_POST['id']; $table = $POST['table']; //Check for existance if (!$id) die('You need to type in a session name.'); else { if (!$table) die('You need to re-enter you session name.'); } //Check for existance in Database mysql_select_db("reh_temp", $connect1); $q_id = mysql_query("SELECT * FROM users WHERE users='$id'"); if (mysql_num_rows($q_id)==0) { //Check Character Length if (strlen($id)<4||strlen($table)<4) die('Please enter a session name that is more than 4 characters.'); else { //Check for Match if ($id==$table) { //Insert value into users table mysql_select_db("reh_temp", $connect1); $q_id_reg = mysql_query("INSERT INTO users VALUES ('$id')"); mysql_select_db("reh_temp", $connect1); $session_table = "CREATE TABLE $table ( password varchar(10) )"; die ('Thanks!'); } else die ('Your session names do not match!'); } } else die ('The session name you choose is already in use. Please choose a different one.'); { ?> <head> <title>ReH-0.1--Create a Session</title> </head> <body bgcolor="#575757"> <center> <font color="#ffffff">Before encrypting your password, a session must be started. We need you to enter a personal session name that you will remember so that you password is protected by this session.</font><br><br> <form action="ReH-0.1.php" method="POST"> <input type="text" maxlength="10" size="10" name="id"><br> <font color="#ffffff">Please choose a session name.</font><br><br> <input type="text" maxlength="10" size="10" name="table"><br> <font color="#ffffff">Please re-enter you session name.</font><br><br> <input type="submit" value="Create Session"> </form> </center> </body> <?php } echo "I'm Working!"; ?> Any help and suggestions would help. Thanks! Dear friends, I wrote a code to extract a text from a pages of a site like this: ************ $handle = @fopen($url, 'r'); $contents = ''; if ($handle) { while (!feof($handle)) { $contents .= fread($handle, 8192); } ************ This code is working properly with many pages just pages those are began with the following tags: ************ ... <body> <form name="aspnetForm" method="post" action="ViewContents.aspx?Contract=cms_Contents_I_News&amp%3br=721192" id="aspnetForm"> <input type="hidden" name="__VIEWSTATE" id=" __VIEWSTATE" value="" /> <input type="hidden" name="__EVENTVALIDATION" id="__EVENTVALIDATION" value="/wEWAwL+raDpAgL3qPzdCwLyp86ZD5mqDm6ZnRL/pRerpqyobvzmy5LB" /> ************ The result of function read() in variable $content is not full. It's just theme of the page without main content. I mean there isn't the story related to id of page (e.g. 721192) in the $content. Why? Is the above <form> affected the result? What can i do? Please help me. I've created both the scripts below. Which seem to work well on their own. The scripts are not interacting at the moment, however I do intend to use this lil $JSONloc (json encoded variable) from code 1, in Code 2. But they are not interacting atm. The Json variable is just a return from a database eg. "New York." and it returns whatever id I give it working fine. This map script = code 2: Will eventually plot a number of locations. Only 1 is set atm, but I've tested it with more, and it runs fine again on its own.
The problem is when I run both scripts together I get problems. In this case it echos the location fine but it doesn't load the map.
Ok so remove the echo statement... and then it says Page cannot be displayed
Ok so remove the PHP and the map works fine. Like WTH?
Do these things even work together? I'm at this 1 day and a half. Please help I've changed the personal details for security.
Code 1 <?php $ider = $_GET['id']; $host = "localhost"; $user = "user"; $password ="pass"; $database = "DB1"; mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT); // connect to mysql database try{ $connect = mysqli_connect($host, $user, $password, $database); } catch (mysqli_sql_exception $ex) { echo 'Error'; } $sql = "SELECT id, Location FROM Db1 WHERE id =$ider"; $result = $connect->query($sql); if ($result->num_rows > 0) { // output data of each row while($row = $result->fetch_assoc()) { $thisloc = $row["Location"]; //get array data $JSONloc = json_encode($thisloc); //change to JSON echo $JSONloc; //test } } else { echo "0 results"; } $conn->close(); ?> Code 2 <!DOCTYPE html> <html> <head> <title>Custom Markers</title> <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no"> <meta charset="utf-8"> <style> /* Always set the map height explicitly to define the size of the div * element that contains the map. */ #map { height: 100%; } /* Optional: Makes the sample page fill the window. */ html, body { height: 90%; width: 70% margin: 0; padding: 0; } </style> </head> <body> <div id="map"></div> <script> var map; function initMap() { map = new google.maps.Map( document.getElementById('map'), {center: new google.maps.LatLng(64.009094, -7.316163), zoom: 13}); var iconBase = 'https://developers.google.com/maps/documentation/javascript/examples/full/images/'; var iconBase2 = 'http://icons.iconarchive.com/icons/paomedia/small-n-flat/32/'; var icons = { // different icons for the map equipment: { icon: 'http://icons.iconarchive.com/icons/icons-land/vista-map-markers/32/Map-Marker-Marker-Outside-Azure-icon.png' }, library: { icon: iconBase2 + 'map-marker-icon.png' }, info: { icon: iconBase + 'info-i_maps.png' } }; var dormant = 'equipment'; var active = 'library'; var later = 64.013376; var longer = -7.307036; // static variables for testing var features = [ { position: new google.maps.LatLng(later, longer), type: active } ]; // Create markers. for (var i = 0; i < features.length; i++) { var marker = new google.maps.Marker({ position: features.position, icon: icons[features.type].icon, map: map }); }; } </script> <script async defer src="https://maps.googleapis.com/maps/api/js?key=bla&callback=initMap"> </script> </body> </html> Edited February 26, 2020 by JonnyDriller |