Jump to content

XCalibre1

Members
  • Posts

    24
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

XCalibre1's Achievements

Member

Member (2/5)

0

Reputation

1

Community Answers

  1. You must have cookies enabled to login. I get this error when trying to log into a calendar, but my cookies are to accept all cookies. This is the Calendar.php There are no cookies going to the calendar, there is just the login feature so anyone with Admin status can login to make changes. <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script> <?php if ( !defined('IN_PHPC') ) { die("Hacking attempt"); } require_once("$phpc_includes_path/Gettext_PHP.php"); require_once("$phpc_includes_path/html.php"); require_once("$phpc_includes_path/util.php"); // Displayed in admin $phpc_version = "2.0.10"; /** * @param string $msg * @return string */ function __($msg) { global $phpc_gettext; if (empty($phpc_gettext)) return $msg; return $phpc_gettext->gettext($msg); } /** * @param string $context * @param string $msg * @return string */ function __p($context, $msg) { global $phpc_gettext; return $phpc_gettext->pgettext($context, $msg); } // checks global variables to see if the user is logged in. /** * @return bool */ function is_user() { global $phpc_user; return $phpc_user->uid > 0; } /** * @return bool */ function is_admin() { global $phpc_user; return $phpc_user->admin; } /** * @param string $username * @param string $password * @return bool */ function login_user($username, $password) { global $phpcdb; $user = $phpcdb->get_user_by_name($username); if(!$user || $user->password !== md5($password)) return false; phpc_do_login($user); return true; } /** * @param PhpcUser $user * @param bool $series_token * @return bool */ function phpc_do_login($user, $series_token = false) { global $phpcdb, $phpc_prefix; $uid = $user->uid; $login_token = phpc_get_token(); $_SESSION["{$phpc_prefix}uid"] = $uid; $_SESSION["{$phpc_prefix}login"] = $login_token; if(!$series_token) { $series_token = phpc_get_token(); $phpcdb->add_login_token($uid, $series_token, $login_token); } else { $phpcdb->update_login_token($uid, $series_token, $login_token); } // TODO: Add a remember me checkbox to the login form, and have the // cookies expire at the end of the session if it's not checked // expire credentials in 30 days. $expiration_time = time() + 30 * 24 * 60 * 60; phpc_set_cookie("{$phpc_prefix}uid", $uid, $expiration_time); phpc_set_cookie("{$phpc_prefix}login", $login_token, $expiration_time); phpc_set_cookie("{$phpc_prefix}login_series", $series_token, $expiration_time); return true; } function phpc_do_logout() { global $phpc_prefix; session_destroy(); $past_time = time() - 3600; phpc_set_cookie("{$phpc_prefix}uid", "", $past_time); phpc_set_cookie("{$phpc_prefix}login", "", $past_time); phpc_set_cookie("{$phpc_prefix}login_series", "", $past_time); } // returns tag data for the links at the bottom of the calendar /** * @return Html */ function footer() { global $phpc_url, $phpc_tz, $phpc_lang; $tag = tag('div', attributes('class="phpc-bar ui-widget-content"'), "[" . __('Language') . ": $phpc_lang]" . " [" . __('Timezone') . ": $phpc_tz]"); if(defined('PHPC_DEBUG')) { $tag->add(tag('a', attributes('href="http://validator.w3.org/check?url=' . phpc_html_escape(rawurlencode($phpc_url)) . '"'), 'Validate HTML')); $tag->add(tag('a', attributes('href="http://jigsaw.w3.org/css-validator/check/referer"'), 'Validate CSS')); } return $tag; } /** * @return array */ function get_languages() { global $phpc_locale_path; static $langs; if(!empty($langs)) return $langs; // create links for each existing language translation $handle = opendir($phpc_locale_path); if(!$handle) soft_error("Error reading locale directory."); $langs = array('en'); while(($filename = readdir($handle)) !== false) { $pathname = "$phpc_locale_path/$filename"; if(strncmp($filename, ".", 1) == 0 || !is_dir($pathname)) continue; if(file_exists("$pathname/LC_MESSAGES/messages.mo")) $langs[] = $filename; } closedir($handle); return $langs; } /** * @return int */ function day_of_week_start() { global $phpc_cal; return $phpc_cal->week_start; } // returns the number of days in the week before the // taking into account whether we start on sunday or monday /** * @param int $month * @param int $day * @param int $year * @return int */ function day_of_week($month, $day, $year) { return day_of_week_ts(mktime(0, 0, 0, $month, $day, $year)); } // returns the number of days in the week before the // taking into account whether we start on sunday or monday /** * @param int $timestamp * @return int */ function day_of_week_ts($timestamp) { $days = date('w', $timestamp); return ($days + 7 - day_of_week_start()) % 7; } // returns the number of days in $month /** * @param int $month * @param int $year * @return false|string */ function days_in_month($month, $year) { return date('t', mktime(0, 0, 0, $month, 1, $year)); } //returns the number of weeks in $month function weeks_in_month($month, $year) { $days = days_in_month($month, $year); // days not in this month in the partial weeks $days_before_month = day_of_week($month, 1, $year); $days_after_month = 6 - day_of_week($month, $days, $year); // add up the days in the month and the outliers in the partial weeks // divide by 7 for the weeks in the month return ($days_before_month + $days + $days_after_month) / 7; } // return the week number corresponding to the $day. function week_of_year($month, $day, $year) { $timestamp = mktime(0, 0, 0, $month, $day, $year); // week_start = 1 uses ISO 8601 and contains the Jan 4th, // Most other places the first week contains Jan 1st // There are a few outliers that start weeks on Monday and use // Jan 1st for the first week. We'll ignore them for now. if(day_of_week_start() == 1) { $year_contains = 4; // if the week is in December and contains Jan 4th, it's a week // from next year if($month == 12 && $day - 24 >= $year_contains) { $year++; $month = 1; $day -= 31; } } else { $year_contains = 1; } // $day is the first day of the week relative to the current month, // so it can be negative. If it's in the previous year, we want to use // that negative value, unless the week is also in the previous year, // then we want to switch to using that year. if($day < 1 && $month == 1 && $day > $year_contains - 7) { $day_of_year = $day - 1; } else { $day_of_year = date('z', $timestamp); $year = date('Y', $timestamp); } /* Days in the week before Jan 1. */ $days_before_year = day_of_week(1, $year_contains, $year); // Days left in the week $days_left = 8 - day_of_week_ts($timestamp) - $year_contains; /* find the number of weeks by adding the days in the week before * the start of the year, days up to $day, and the days left in * this week, then divide by 7 */ return ($days_before_year + $day_of_year + $days_left) / 7; } function year_of_week_of_year($month, $day, $year) { $timestamp = mktime(0, 0, 0, $month, $day, $year); // week_start = 1 uses ISO 8601 and contains the Jan 4th, // Most other places the first week contains Jan 1st // There are a few outliers that start weeks on Monday and use // Jan 1st for the first week. We'll ignore them for now. if(day_of_week_start() == 1) { $year_contains = 4; // if the week is in December and contains Jan 4th, it's a week // from next year if($month == 12 && $day - 24 >= $year_contains) { return $year + 1; } } else { return $year; } // $day is the first day of the week relative to the current month, // so it can be negative. If it's in the previous year, we want to use // that negative value, unless the week is also in the previous year, // then we want to switch to using that year. if($day < 1 && $month == 1 && $day > $year_contains - 7) { return $year; } else { return date('Y', $timestamp); } } function create_event_link($text, $action, $eid, $attribs = false) { return create_action_link($text, $action, array('eid' => $eid), $attribs); } function create_occurrence_link($text, $action, $oid, $attribs = false) { return create_action_link($text, $action, array('oid' => $oid), $attribs); } function create_action_link_with_date($text, $action, $year = false, $month = false, $day = false, $attribs = false) { $args = array(); if($year !== false) $args["year"] = $year; if($month !== false) $args["month"] = $month; if($day !== false) $args["day"] = $day; return create_action_link($text, $action, $args, $attribs); } /** * @param $action * @param bool $year * @param bool $month * @param bool $day * @param array $args * @return string */ function create_action_url($action, $year = false, $month = false, $day = false, $args = array()) { global $phpc_script, $vars; if($year !== false) $args["year"] = $year; if($month !== false) $args["month"] = $month; if($day !== false) $args["day"] = $day; $url ="".$phpc_script."?"; if(isset($vars["phpcid"])) $url .= "phpcid=" . phpc_html_escape($vars["phpcid"]) . "&amp;"; $url .= "action=" . phpc_html_escape($action); foreach ($args as $key => $value) { if (empty($value)) continue; if (is_array($value)) { foreach ($value as $v) { $url .= "&amp;" . phpc_html_escape("{$key}[]=$v"); } } else $url .= "&amp;" . phpc_html_escape("$key=$value"); } return $url; } /** * @param string $text * @param string $action * @param string[] $args * @param bool|AttributeList $attribs * @return Html */ function create_action_link($text, $action, $args = array(), $attribs = false) { global $phpc_script, $vars; $url = "href=\"$phpc_script?"; if(isset($vars["phpcid"])) $url .= "phpcid=" . phpc_html_escape($vars["phpcid"]) . "&amp;"; $url .= "action=" . phpc_html_escape($action); foreach ($args as $key => $value) { if (empty($value)) continue; if (is_array($value)) { foreach ($value as $v) { $url .= "&amp;" . phpc_html_escape("{$key}[]=$v"); } } else $url .= "&amp;" . phpc_html_escape("$key=$value"); } $url .= '"'; if($attribs !== false) { $as = attributes($url, $attribs); } else { $as = attributes($url); } return tag('a', $as, $text); } // takes a menu $html and appends an entry /** * @param Html $html * @param string $name * @param string $action * @param string[] $args * @param bool|AttributeList $attribs */ function menu_item_append(&$html, $name, $action, $args = array(), $attribs = false) { $name=str_replace(' ','&nbsp;',$name); /*not breaking space on menus*/ if(!is_object($html)) { soft_error('Html is not a valid Html class.'); } $html->add(create_action_link($name, $action, $args, $attribs)); $html->add("\n"); } // takes a menu $html and appends an entry with the date /** * @param Html $html * @param string $name * @param string $action * @param bool|int $year * @param bool|int $month * @param bool|int $day * @param bool|AttributeList $attribs */ function menu_item_append_with_date(&$html, $name, $action, $year = false, $month = false, $day = false, $attribs = false) { $name = str_replace(' ','&nbsp;',$name); if(!is_object($html)) { soft_error('Html is not a valid Html class.'); } $html->add(create_action_link_with_date($name, $action, $year, $month, $day, $attribs)); $html->add("\n"); } // same as above, but prepends the entry /** * @param Html $html * @param string $name * @param string $action * @param string[] $args * @param bool|AttributeList $attribs */ function menu_item_prepend(&$html, $name, $action, $args = array(), $attribs = false) { if(!is_object($html)) { soft_error('Html is not a valid Html class.'); } $html->prepend("\n"); $html->prepend(create_action_link($name, $action, $args, $attribs)); } // creates a hidden input for a form // returns tag data for the input /** * @param string $name * @param mixed $value * @return Html */ function create_hidden($name, $value) { return tag('input', attributes("name=\"$name\"", "value=\"$value\"", 'type="hidden"')); } // creates a submit button for a form // return tag data for the button /** * @param mixed $value * @return Html */ function create_submit($value) { return tag('input', attributes('name="submit"', "value=\"$value\"", 'type="submit"')); } /** * creates a text entry for a form * returns tag data for the entry * * @param string $name * @param mixed $value * @return Html */ function create_text($name, $value = false) { $attributes = attributes("name=\"$name\"", "id=\"$name\"", 'type="text"'); if($value !== false) { $attributes->add("value=\"$value\""); } return tag('input', $attributes); } // creates a password entry for a form // returns tag data for the entry /** * @param string $name * @return Html */ function create_password($name) { return tag('input', attributes("name=\"$name\"", "id=\"$name\"", 'type="password"')); } // creates a checkbox for a form // returns tag data for the checkbox /** * @param string $name * @param mixed $value * @param bool $checked * @param bool|string $label * @return array|Html */ function create_checkbox($name, $value, $checked = false, $label = false) { $attributes = attributes("id=\"$name\"", "name=\"$name\"", 'type="checkbox"', "value=\"$value\""); if(!empty($checked)) $attributes->add('checked="checked"'); $input = tag('input', $attributes); if($label !== false) return array($input, tag('label', attributes("for=\"$name\""), $label)); else return $input; } // $title - string or html element displayed by default // $values - Array of URL => title // returns an html structure for a dropdown box that will change the page // to the URL from $values when an element is selected /** * @param mixed $title * @param mixed $values * @return Html */ function create_dropdown_list($title, $values) { $list = tag('ul'); foreach($values as $key => $value) { $list->add(tag('li', tag('a', attrs("href=\"$key\""), $value))); } return tag('span', attrs('class="phpc-dropdown-list"'), tag('span', attrs('class="phpc-dropdown-list-header"'), tag('span', attrs('class="phpc-dropdown-list-title"'), $title)), $list); } // creates the user menu // returns tag data for the menu /** * @return Html */ function userMenu() { global $action, $phpc_user; $welcome = __('Welcome') . '&nbsp;' . $phpc_user->username; $span = tag('span'); $html = tag('div', attributes('class="phpc-logged ui-widget-content"'), $welcome, $span); if($action != 'settings') menu_item_append($span, __('Settings'), 'settings'); if(is_user()) { menu_item_append($span, __('Log out'), 'logout', array('lasturl' => phpc_html_escape(rawurlencode($_SERVER['QUERY_STRING'])))); } else { menu_item_append($span, __('Log in'), 'login', array('lasturl' => phpc_html_escape(rawurlencode($_SERVER['QUERY_STRING'])))); } return $html; } // creates the navbar for the top of the calendar // returns tag data for the navbar /** * @return Html */ function navbar() { global $action, $year, $month, $day, $phpc_cal; $html = tag('div', attributes('class="phpc-bar ui-widget-header"')); $args = array('year' => $year, 'month' => $month, 'day' => $day); if($phpc_cal->can_write() && $action != 'add') { menu_item_append($html, __('Add Event'), 'event_form', $args); } if($action != 'search') { menu_item_append($html, __('Search'), 'search', $args); } if($action != 'display_month') { menu_item_append($html, __('View Month'), 'display_month', $args); } if($action == 'display_event') { menu_item_append($html, __('View date'), 'display_day', $args); } if($phpc_cal->can_admin() && $action != 'cadmin') { menu_item_append($html, __('Calendar Admin'), 'cadmin'); } if(is_admin() && $action != 'admin') { menu_item_append($html, __('Admin'), 'admin'); } return $html; } // creates an array from $start to $end, with an $interval /** * @param int $start * @param int $end * @param int $interval * @param mixed $display * @return array */ function create_sequence($start, $end, $interval = 1, $display = false) { $arr = array(); for ($i = $start; $i <= $end; $i += $interval){ if($display) { $arr[$i] = call_user_func($display, $i); } else { $arr[$i] = $i; } } return $arr; } /** * @return array */ function get_config_options() { static $options = NULL; if($options === NULL) { $options = init_config_options(); } return $options; } /** * @return array */ function init_config_options() { $languages = array("" => __("Default")); foreach(get_languages() as $language) { $languages[$language] = $language; } // name, text, type, value(s) return array( array('week_start', __('Week Start'), PHPC_DROPDOWN, array( 0 => __('Sunday'), 1 => __('Monday'), 6 => __('Saturday') )), array('hours_24', __('24 Hour Time'), PHPC_CHECK), array('title', __('Calendar Title'), PHPC_TEXT), array('subject_max', __('Maximum Subject Length'), PHPC_TEXT, 50), array('events_max', __('Events Display Daily Maximum'), PHPC_TEXT, 8), array('anon_permission', __('Public Permissions'), PHPC_DROPDOWN, array( __('Cannot read nor write events'), __('Can read but not write events'), __('Can create but not modify events'), __('Can create and modify events') ) ), array('timezone', __('Default Timezone'), PHPC_MULTI_DROPDOWN, get_timezone_list()), array('language', __('Default Language'), PHPC_DROPDOWN, $languages), array('date_format', __('Date Format'), PHPC_DROPDOWN, get_date_format_list()), array('theme', __('Theme'), PHPC_DROPDOWN, get_theme_list()), ); } /** * @return array */ function get_theme_list() { $themes = array('base', 'black-tie', 'blitzer', 'cupertino', 'dark-hive', 'dot-luv', 'eggplant', 'excite-bike', 'flick', 'hot-sneaks', 'humanity', 'le-frog', 'mint-choc', 'overcast', 'pepper-grinder', 'redmond', 'smoothness', 'south-street', 'start', 'sunny', 'swanky-purse', 'trontastic', 'ui-darkness', 'ui-lightness', 'vader'); $theme_list = array(NULL => __('Default')); foreach($themes as $theme) { $theme_list[$theme] = $theme; } return $theme_list; } /** * @return array */ function get_timezone_list() { $timezones = array(); $timezones[__("Default")] = ""; foreach(timezone_identifiers_list() as $timezone) { $sp = explode("/", $timezone, 2); $continent = $sp[0]; if(empty($sp[1])) { $timezones[$continent] = $timezone; } else { $area = $sp[1]; if(empty($timezones[$continent])) $timezones[$continent] = array(); $timezones[$continent][$timezone] = $area; } } return $timezones; } /** * @return array */ function get_date_format_list() { return array( __("Month Day Year"), __("Year Month Day"), __("Day Month Year")); } /** * @return Html */ function display_phpc() { global $phpc_messages, $phpc_redirect, $phpc_script, $phpc_prefix, $phpc_home_url, $phpc_cal, $phpcdb; $navbar = false; try { $content = do_action(); $navbar = navbar(); if(sizeof($phpc_messages) > 0) { $messages = tag('div', attrs('class="phpc-message"')); foreach($phpc_messages as $message) { $messages->add($message); } // If we're redirecting, the messages might not get // seen, so don't clear them if(empty($phpc_redirect)) $_SESSION[$phpc_prefix . 'messages'] = null; } else { $messages = ''; } $list = array(); foreach($phpcdb->get_calendars() as $calendar) { if($calendar->can_read()) { $list[$phpc_home_url . '?phpcid=' . $calendar->get_cid()] = $calendar->get_title(); } } return tag('div', attributes('class="php-calendar ui-widget"'), userMenu(), tag('br', attrs('style="clear:both;"')), tag('h1', attrs('class="ui-widget-header"'), create_dropdown_list(tag('a', attrs("href='$phpc_home_url?phpcid={$phpc_cal->get_cid()}'", 'class="phpc-dropdown-list-title"'), $phpc_cal->get_title()), $list)), $navbar, $messages, $content, footer()); } catch(PermissionException $e) { $results = tag(''); // TODO: make navbar show if there is an error in do_action() if($navbar !== false) $results->add($navbar); $msg = __('You do not have permission to do that: ') . $e->getMessage(); $results->add(tag('div', attrs('class="phpc-message ui-state-error"'), $msg)); if(is_user()) return $results; else return message_redirect($msg, "$phpc_script?action=login"); } catch(Exception $e) { $results = tag(''); if($navbar !== false) $results->add($navbar); $results->add(tag('div', attrs('class="phpc-main"'), tag('h2', __('Error')), tag('p', $e->getMessage()), tag('h3', __('Backtrace')), tag('pre', phpc_html_escape($e->getTraceAsString())))); return $results; } } /** * @return mixed */ function do_action() { global $action, $phpc_includes_path; $action_file = "$phpc_includes_path/$action.php"; if(!preg_match('/^\w+$/', $action) || !file_exists($action_file)) soft_error(__('Invalid action')); require_once($action_file); $action_output = call_user_func($action); return $action_output; } // takes a number of the month, returns the name /** * @param int $month * @return string */ function month_name($month) { global $month_names; $month = ($month - 1) % 12 + 1; return $month_names[$month]; } //takes a day number of the week, returns a name (0 for the beginning) /** * @param int $day * @return string */ function day_name($day) { global $day_names; $day = $day % 7; return $day_names[$day]; } /** * @param int $month * @return string */ function short_month_name($month) { global $short_month_names; $month = ($month - 1) % 12 + 1; return $short_month_names[$month]; } function verify_token() { global $vars, $phpc_token; if(!is_user()) return; if(empty($vars["phpc_token"]) || $vars["phpc_token"] != $phpc_token) { //echo "<pre>real token: $phpc_token\n"; //echo "form token: {$vars["phpc_token"]}</pre>"; soft_error(__("Secret token mismatch. Possible request forgery attempt.")); } } /** * @param string $path * @return array */ function get_header_tags($path) { global $phpc_cal; if(defined('PHPC_DEBUG')) $jq_min = ''; else $jq_min = '.min'; $theme = $phpc_cal->theme; if(empty($theme)) $theme = 'base'; $jquery_version = "3.6.0"; $jqueryui_version = "1.13.1"; $showdown_version = "1.9.1"; return array( tag('link', attrs('rel="stylesheet"', 'type="text/css"', "href=\"$path/phpc.css\"")), tag('link', attrs('rel="stylesheet"', 'type="text/css"', "href=\"//ajax.googleapis.com/ajax/libs/jqueryui/$jqueryui_version/themes/$theme/jquery-ui$jq_min.css\"")), tag('link', attrs('rel="stylesheet"', 'type="text/css"', "href=\"$path/jquery-ui-timepicker.css\"")), tag("script", attrs("src=\"//ajax.googleapis.com/ajax/libs/jquery/$jquery_version/jquery$jq_min.js\""), ''), tag("script", attrs("src=\"//ajax.googleapis.com/ajax/libs/jqueryui/$jqueryui_version/jquery-ui$jq_min.js\""), ''), tag('script', attrs("src=\"$path/phpc.js\""), ''), tag("script", attrs("src=\"$path/jquery.ui.timepicker.js\""), ''), tag("script", attrs("src=\"$path/jquery.hoverIntent.minified.js\""), ''), tag("script", attrs("src=\"$path/spectrum.js\""), ''), tag('link', attrs('rel="stylesheet"', 'type="text/css"', "href=\"$path/spectrum.css\"")), tag("script", attrs("src=\"https://cdnjs.cloudflare.com/ajax/libs/showdown/$showdown_version/showdown.min.js\""), ''), ); } /** * @param $path */ function embed_header($path) { echo tag('', get_header_tags($path))->toString(); } // $element: { name, text, type, value(s) } /** * @param array $element * @param mixed $default * @return array|Html */ function create_config_input($element, $default = false) { $name = $element[0]; $text = $element[1]; $type = $element[2]; $value = false; if(isset($element[3])) $value = $element[3]; switch($type) { case PHPC_CHECK: if($default == false) $default = $value; $input = create_checkbox($name, '1', $default, $text); break; case PHPC_TEXT: if($default == false) $default = $value; $input = create_text($name, $default); break; case PHPC_DROPDOWN: $input = create_select($name, $value, $default); break; case PHPC_MULTI_DROPDOWN: $input = create_multi_select($name, $value, $default); break; default: soft_error(__('Unsupported config type') . ": $type"); } return $input; } /* Make a timestamp from the input fields $prefix-time and $prefix-date uses $phpc_cal->date_format to determine the format of the date if there's no $prefix-time, uses values passed as parameters */ /** * @param string $prefix * @param int $hour * @param int $minute * @param int $second * @return false|int */ function get_timestamp($prefix, $hour = 0, $minute = 0, $second = 0) { global $vars, $phpc_cal; if(empty($vars["$prefix-date"])) soft_error(sprintf(__("Required field \"%s\" was not set."), "$prefix-date")); if(!empty($vars["$prefix-time"])) { if(!preg_match('/(\d+)[:\.](\d+)\s?(\w+)?/', $vars["$prefix-time"], $time_matches)) { soft_error(sprintf(__("Malformed \"%s\" time: \"%s\""), $prefix, $vars["$prefix-time"])); } $hour = $time_matches[1]; $minute = $time_matches[2]; if(isset($time_matches[3])) { $period = $time_matches[3]; if($hour == 12) $hour = 0; if(strcasecmp("am", $period) == 0) { // AM } else if(strcasecmp("pm", $period) == 0) { $hour += 12; } else { soft_error(__("Unrecognized period: ") . $period); } } } if(!preg_match('/(\d+)[\.\/\-\ ](\d+)[\.\/\-\ ](\d+)/', $vars["$prefix-date"], $date_matches)) { soft_error(sprintf(__("Malformed \"%s\" date: \"%s\""), $prefix, $vars["$prefix-date"])); } switch($phpc_cal->date_format) { case 0: // Month Day Year $month = $date_matches[1]; $day = $date_matches[2]; $year = $date_matches[3]; break; case 1: // Year Month Day $year = $date_matches[1]; $month = $date_matches[2]; $day = $date_matches[3]; break; case 2: // Day Month Year $day = $date_matches[1]; $month = $date_matches[2]; $year = $date_matches[3]; break; default: soft_error(__("Invalid date_format.")); } return mktime($hour, $minute, $second, $month, $day, $year); } /** * @param string $name * @param mixed $value * @param int $expire * @return bool */ function phpc_set_cookie($name, $value, $expire = 0) { return setcookie($name, $value, $expire, "", "", false, true); } Then the code to sign in to admin section that keeps saying I need cookies enabled. if(!defined('IN_PHPC')) { die("Hacking attempt"); } /** * @return Html */ function login() { global $vars, $phpc_script; $html = tag('div'); //Check password and username if(isset($vars['username'])){ $user = $vars['username']; $password = $vars['password']; if(login_user($user, $password)){ $url = $phpc_script; if(!empty($vars['lasturl'])) { $url .= '?' . urldecode($vars['lasturl']); } redirect($url); return tag('h2', __('Logged in.')); } $html->add(tag('h2', __('Sorry, Invalid Login'))); } $html->add(login_form()); return $html; } /** * @return Html */ function login_form() { global $vars, $phpc_script; $submit_data = tag('td', attributes('colspan="2"'), create_hidden('action', 'login'), create_submit(__('Log in'))); if(!empty($vars['lasturl'])) { $lasturl = phpc_html_escape(rawurlencode($vars['lasturl'])); $submit_data->prepend(create_hidden('lasturl', $lasturl)); } return tag('form', attributes("action=\"$phpc_script\"", 'method="post"'), tag('table', tag('caption', __('Log in')), tag('thead', tag('tr', tag('th', attributes('colspan="2"'), __('You must have cookies enabled to login.')))), tag('tfoot', tag('tr', $submit_data)), tag('tbody', tag('tr', tag('th', tag('label', attributes('for="username"'), __('Username'))), tag('td', create_text('username'))), tag('tr', tag('th', tag('label', attributes('for="password"'), __('Password'))), tag('td', create_password('password')))))); } Any ideas how to fix or just turn the cookies off? Thank you.
  2. Okay, I'm not sure if this is the best way, but I changed it to: <?php $time = date("l jS \of F Y h:i:s A", strtotime("$date")+7200) . "\n"; ?> And it works
  3. also to make it clearer..... the time in occurance is 2023-04-11 15:00:00 with date as the field, which is right.... 5am.... and then I used the formula $date = $row["start_ts"]; which shows the above time..... then I use the next formula $time = date("l jS \of F Y h:i:s A", strtotime("$date")) . "\n"; it shows the right date, but the ti me is 2 hours still behind, showing 3am using the server time, even though I have set the serve timezone to Central.
  4. If you need the whole code to the action_page.php hre it is without the databasae connections <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script> <?php date_default_timezone_set('America/Chicago'); $timezone = date_default_timezone_get(); echo "Server $timezone"; ?> <br><br> <?php $fname = $_GET['fname']; $lname = $_GET['lname']; $phone = $_GET['phone']; $dropdown = $_GET['dropdown']; $oid = $_GET['oid']; $dived = $_GET['dove']; $email = $_GET['email']; $date = $_GET['date']; echo" <div width='500px'>"; echo" <form method='post' id='formABCs'>"; echo" <fieldset disabled>"; echo" <legend>Your Name</legend>"; echo" <input type='text' class='textarea' name='name' id='textarea' readonly placeholder='$fname $lname'><br>"; echo" </fieldset>"; echo" <fieldset disabled>"; echo" <legend>Your Email</legend>"; echo" <input type='text' class='textarea' name='email' id='textarea' readonly placeholder='$email'></textarea>"; echo" </fieldset>"; echo" <fieldset disabled>"; echo" <legend>Your Phone Number</legend>"; echo" <input type='text' class='textarea' name='phone' id='textarea' readonly placeholder='$phone'></textarea>"; echo" </fieldset>"; echo" <fieldset disabled>"; echo" <legend>Have you ever dived before</legend>"; echo" <input type='text' class='textarea' name='dived' id='textarea' readonly placeholder='$dived'></textarea>"; echo" </fieldset>"; echo" <fieldset disabled>"; echo" <legend>How many in your party</legend>"; echo" <input type='text' class='textarea' name='dropdown' id='textarea' readonly placeholder='$dropdown'></textarea>"; echo" </fieldset>"; ?> $time = date("l jS \of F Y h:i:s A", strtotime("$date")) . "\n"; echo" <fieldset disabled>"; echo" <legend>Your Reservation Date</legend>"; echo" <input type='text' class='textarea' name='date' id='textarea' readonly placeholder='$time'></textarea>"; echo" </fieldset>"; $alph = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"; $code=''; for($i=0;$i<15;$i++){ $code .= $alph[rand(0, 35)]; } echo" <button name='submit' id='btn' value='Submit' onclick\"hideButton()\">Click to Verify Information</button>"; echo" </form>"; ?> <script> function hideButton(){ document.getElementById('btn').style.display= 'none'; $("#btnSubmit").attr("disabled", true); } </script> <script> $(document).ready(function() { ///// show /// $('#b1').click(function(){ if($('#b1').attr('value')=='Hide'){ $(this).val('Show'); // change the value to Show $('#formABCs').hide(); }else{ $(this).val('Your Reservation Has Successfully Been Created. See you at the beach!'); // change the value to Hide $('#formABCs').hide(); } }) }) </script> <?php if (isset($_POST["submit"])) { $fname = $_GET['fname']; $lname = $_GET['lname']; $phone = $_GET['phone']; $dropdown = $_GET['dropdown']; $oid = $_GET['oid']; $dived = $_GET['dove']; $email = $_GET['email']; if(! get_magic_quotes_gpc() ) { $fname = addslashes ($fname); $lname = addslashes ($lname); $email = addslashes ($email); $phone = addslashes ($phone); $dived = addslashes ($dived); $dropdown = addslashes ($dropdown); $date = addslashes ($date); $newdate = addslashes ($newdate); $resnum = addslashes ($code); } else { $fname = $_GET['name']; $email = $_GET['email']; $lname = $_GET['lname']; $phone = $_GET['phone']; $dived = $_GET['dived']; $dropdown = $_GET['dropdown']; } $sql = "INSERT INTO reservations ". "(fname,email,lname,phone,dived,dropdown,reserved,resnum) "."VALUES ". "('$fname','$email','$lname','$phone','$dived','$dropdown','$newdate','$resnum')"; if ($conn->query($sql)) { echo" <input type='button' id='b1' value='Your Reservation Is Processing...Click Here to Finilize!'><br><br>"; echo" <textarea class='reserved' name='reserved' id='reserved'>$code</textarea>"; echo" <textarea class='save' id='blink'> Please copy, paste, and save your Reservation Number!</textarea>"; echo" </form>"; } if ($conn->connect_error) { printf("Could not insert record into table: %s<br />", $mysqli→error); } $conn->close(); } ?> <style> legend { background-color: #fff; color: #000; padding: 3px 6px; } *:read-only { font-weight: bold; color: red; font-size: 12px; } div { width: 37%; margin: auto; } input { border: none; outline: none; font-size:1.3em; padding:.5em; white-space: normal; font-weight: bold; resize: none; width: 500px } input:read-only { background-color: yellow; } textarea { resize: none; height: 30px; } .reserved { font-size: 20px; width: 500px; text-align: center; } .save { font-size: 18px; width: 525px; height: 45px; text-align: center; border: none; outline: none; overflow: hidden; } #submit { border:1px solid #000; color:#000; padding:0; overflow:hidden; height:40px; font-weight:bold; text-align:center; margin-left: 10px; } #submit:hover { background:#000; color:#fff } #blink { font-size: 20px; font-weight: bold; font-family: sans-serif; color: #1c87c9; transition: 0.4s; } </style> <script type="text/javascript"> var blink = document.getElementById('blink'); setInterval(function() { blink.style.opacity = (blink.style.opacity == 0 ? 1 : 0); }, 1000); </script> But it sthows 2 hours behind...... I have it set for 5 am but the reservation says 3am..... and I'm central time and the server is sset to central time, so it makes no sense to me. It does give the correct date chosen for the day of reservervation; it's the time messed up.
  5. Then the time I use on the page I use the GET I already sh owed you: $time = date("l jS \of F Y h:i:s A", strtotime("$date")) . "\n"; echo" <fieldset disabled>"; echo" <legend>Your Reservation Date</legend>"; echo" <input type='text' class='textarea' name='date' id='textarea' readonly placeholder='$time'></textarea>"; echo" </fieldset>";
  6. Here is my code.... I use the $_GET on the next page... Code is a mess... but I clean it up later. <?php date_default_timezone_set('America/Chicago'); $timezone = date_default_timezone_get(); echo "Server $timezone"; ?> <script> var currentTime = new Date(); var hours = currentTime.getHours(); var minutes = currentTime.getMinutes(); var suffix = "AM"; if (hours >= 12) { suffix = "PM"; hours = hours - 12; } if (hours == 0) { hours = 12; } if (minutes < 10) { minutes = "0" + minutes; } document.write("<b>" + hours + ":" + minutes + " " + suffix + "</b>"); </script> <?php /* * Copyright 2012 Sean Proctor * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /* This file has the functions for the main displays of the calendar */ if ( !defined('IN_PHPC') ) { die("Hacking attempt"); } // Full view for a single event /** * @return Html|string */ function display_event() { global $vars; if(!empty($vars['contentType']) && $vars['contentType'] == 'json') return display_event_json(); if(isset($vars['oid'])) return display_event_by_oid($vars['oid']); if(isset($vars['eid'])) return display_event_by_eid($vars['eid']); // If we get here, we did something wrong soft_error(__("Invalid arguments.")); } /** * @param int $oid * @return Html */ function display_event_by_oid($oid) { global $phpcdb, $year, $month, $day; $event = $phpcdb->get_occurrence_by_oid($oid); $eid = $event->get_eid(); if(!$event->can_read()) { return tag('p', __("You do not have permission to read this event.")); } $event_header = tag('div', attributes('class="phpc-event-header"'), tag('div',attributes('class="phpc-event-creator"'), __('by').' ', tag('cite', $event->get_author()))); $category = $event->get_category(); if(!empty($category)) $event_header->add(tag('div',attributes('class="phpc-event-cats"'), __('Category') . ': ' . $category)); $event_header->add(tag('div',attributes('class="phpc-event-time"'), __('When').": ".$event->get_datetime_string())); if(!empty($event->mtime)) $event_header->add(tag('div', __('Last modified at: '), $event->get_mtime_string())); $menu_tag = tag('div', attrs('class="phpc-bar ui-widget-content"')); // Add modify/delete links if this user has access to this event. if($event->can_modify()) { $menu_tag->add(array(create_event_link(__('Modify'), 'event_form', $eid), "\n", create_event_link(__('Delete'), 'event_delete', $eid), "\n", create_occurrence_link(__('Modify Occurrence'), 'occur_form', $oid), "\n", create_occurrence_link(__('Remove Occurrence'), 'occurrence_delete', $oid), "\n")); } $occurrences = $phpcdb->get_occurrences_by_eid($eid); //$occurrence_div = tag('div', ); $i = 0; while($i < sizeof($occurrences)) { if($occurrences[$i]->get_oid() == $oid) break; $i++; } // if we have a previous event $prev = $i - 1; if($prev >= 0) { $prev_occur = $occurrences[$prev]; $menu_tag->add(create_occurrence_link( __('Previous occurrence on') . " " . $prev_occur->get_date_string(), 'display_event', $prev_occur->get_oid()), ' '); } // if we have a future event $next = $i + 1; if($next < sizeof($occurrences)) { $next_occur = $occurrences[$next]; $menu_tag->add(create_occurrence_link( __('Next occurrence on') . " " . $next_occur->get_date_string(), 'display_event', $next_occur->get_oid()), ' '); } $menu_tag->add(create_event_link(__('View All Occurrences'), 'display_event', $eid)); $event_header->add($menu_tag); $year = $event->get_start_year(); $month = $event->get_start_month(); $day = $event->get_start_day(); $desc_tag = tag('div', tag('h3', __("Description")), tag('p', attributes('class="phpc-desc"'), $event->get_desc())); return tag('div', attributes('class="phpc-main phpc-event"'), tag('h2', $event->get_subject()), $event_header, $desc_tag); } /** * @param int $eid * @return Html */ function display_event_by_eid($eid) { global $phpcdb, $year, $month, $day; $event = new PhpcEvent($phpcdb->get_event_by_eid($eid)); if(!$event->can_read()) { return tag('p', __("You do not have permission to read this event.")); } $event_header = tag('div', attributes('class="phpc-event-header"'), tag('div', __('by').' ', tag('cite', $event->get_author()))); if(!empty($event->mtime)) $event_header->add(tag('div', __('Last modified at: '), $event->get_mtime_string())); $category = $event->get_category(); if(!empty($category)) $event_header->add(tag('div', __('Category') . ': ' . $category)); // Add modify/delete links if this user has access to this event. if($event->can_modify()) { $event_header->add(tag('div', attrs('class="phpc-bar ui-widget-content"'), create_event_link(__('Modify'), 'event_form', $eid), "\n", create_event_link(__('Add Occurrence'), 'occur_form', $eid), "\n", create_event_link(__('Delete'), 'event_delete', $eid))); } $desc_tag = tag('div', tag('h3', __("Description")), tag('p', attributes('class="phpc-desc"'), $event->get_desc())); $occurrences_tag = tag('ul'); $occurrences = $phpcdb->get_occurrences_by_eid($eid); $set_date = false; foreach($occurrences as $occurrence) { if(!$set_date) { $year = $occurrence->get_start_year(); $month = $occurrence->get_start_month(); $day = $occurrence->get_start_day(); } $oid = $occurrence->get_oid(); $occ_tag = tag('li', attrs('class="ui-widget-content"'), create_occurrence_link( $occurrence->get_date_string() . ' ' . __('at') . ' ' . $occurrence->get_time_span_string(), 'display_event', $oid)); if($event->can_modify()) { $occ_tag->add(" ", create_occurrence_link(__('Edit'), 'occur_form', $oid), " ", create_occurrence_link(__('Remove'), 'occurrence_delete', $oid)); } $occurrences_tag->add($occ_tag); } return tag('div', attributes('class="phpc-main phpc-event"'), tag('h2', $event->get_subject()), $event_header, $desc_tag, tag ('div',attributes('class="phpc-occ"'),tag('h3', __('Occurrences')), $occurrences_tag)); } // generates a JSON data structure for a particular event /** * @return string */ function display_event_json() { global $phpcdb, $vars; if(!isset($vars['oid'])) return ""; $event = $phpcdb->get_occurrence_by_oid($vars['oid']); if(!$event->can_read()) return ""; $time_str = $event->get_time_span_string(); $date_str = $event->get_date_string(); if(empty($category)) $category_text = ''; else $category_text = __('Category') . ': ' . $event->get_category(); if ($time_str!="") $time="$date_str " . __("from") . " $time_str"; else $time="$date_str "; return json_encode(array("title" => $event->get_subject(), "time" => $time, "body" => $event->get_desc())); } function get_event_by_oid($oid) { $events_table = SQL_PREFIX . 'events'; $occurrences_table = SQL_PREFIX . 'occurrences'; $users_table = SQL_PREFIX . 'users'; $cats_table = SQL_PREFIX . 'categories'; $reservations_table = SQL_PREFIX . 'date'; $query = "SELECT " . $this->get_event_fields() .", `username`, `name`, `bg_color`, `text_color`\n" ."FROM `$events_table`\n" ."LEFT JOIN `$occurrences_table` USING (`eid`)\n" ."LEFT JOIN `$users_table` ON `uid` = `owner`\n" ."LEFT JOIN `$cats_table` USING (`catid`)\n" ."LEFT JOIN `$reservations` USING (`date`)\n" ."WHERE `oid` = '$oid'\n"; $sth = $this->dbh->query($query) or $this->db_error(__('Error in get_event_by_oid'), $query); $result = $sth->fetch_assoc() or soft_error(__("Event doesn't exist with oid") . ": $oid"); return $result; } echo" <br><br><div class='openBtn'>"; echo" <button class='openButton' onclick='openForm()'><strong>Make Reservation</strong></button>"; echo" </div>"; echo" <div class='loginPopup'>"; echo" <div class='formPopup' id='popupForm'>"; echo" <form action='/calendar/src/action_page.php' class='formContainer'>"; echo" <h2>Reservation Form</h2>"; echo" <label for='fname'>"; echo" <strong>First Name</strong>"; echo" </label>"; echo" <input type='text' class='fname' id='fname' placeholder='First Name' name='fname' required>"; echo" <input type='text' id='oid' value='$_GET[oid]' name='oid' hidden >"; echo" <label for='lname'>"; echo" <strong>Last Name</strong>"; echo" </label>"; echo" <input type='text' class='lname' id='lname' placeholder='Last Name' name='lname' required>"; echo" <strong><label for='phone'>Phone Number:</label></strong><br>"; echo" <input type='tel' class='mytext' id='phone' name='phone' placeholder=' 123-459-6780' pattern='[0-9]{3}-[0-9]{3}-[0-9]{4}' required><br>"; echo" <small>Format: 123-459-6780</small><br><br>"; echo" <label for='email'>"; echo" <strong>Email<br></strong>"; echo" </label>"; echo" <input type='email' id='email'class='email' placeholder='test@example.com' name='email' required><br><br>"; echo" <label for='dropdown'>"; echo" <strong>How many in your party?</strong>&nbsp;"; echo" </label>"; echo" <select name = 'dropdown' id = 'wgtmsr' name = 'dropdown' required>"; echo" <option value = '1' selected>1</option>"; echo" <option value = '2'>2</option>"; echo" <option value = '3'>3</option>"; echo" <option value = '4'>4</option>"; echo" <option value = '5'>5</option>"; echo" <option value = '6'>6</option>"; echo" <option value = '7'>7</option>"; echo" <option value = '8'>8</option>"; echo" </select><br><br>"; echo" <label for='dove'>"; echo" <strong>Have you ever dived before?</strong>&nbsp;"; echo" </label>"; echo" <select name = 'dove' id = 'dove' name = 'dove' required>"; echo" <option value = 'No' selected>No</option>"; echo" <option value = 'Yes'>Yes</option>"; echo" </select><br><br>"; echo" <textarea name='summary'"; echo" rows='10' cols='32' readonly noborder>"; echo" We take pride in using profressional cleaning supplies on our masks and snorkels, to ensure they are germ free from being used, and is included in the price of your dive. If you are uncomfortable using them, and you do wish to purchase one, it will be an additional $45.00 to get your own."; echo" </textarea><br /><br />"; echo" <button type='submit' class='btn' onclick>Make Your Reservation Now</button>"; echo" <button type='button' class='btn cancel' onclick='closeForm()'>Close</button>"; echo" </form>"; echo" </div>"; echo" </div>"; ?> <script> function openForm() { document.getElementById('popupForm').style.display = 'block'; } </script> <script> function closeForm() { document.getElementById('popupForm').style.display = 'none'; } </script> <style> * { box-sizing: border-box; } .dropbtn { background-color: #04AA6D; color: white; padding: 16px; font-size: 16px; border: none; } .dropdown { position: relative; display: inline-block; } #fname{ height: 40px; width: 260px; background-color: #F5F5F5; } #lname{ height: 40px; width: 260px; background-color: #F5F5F5; } #wgtmsr{ height: 25px; } #dove{ height: 25px; } #email{ height: 40px; width: 260px; background-color: #F5F5F5; } .mytext { width: 260px; height: 40px; background-color: #F5F5F5; } textarea { border: none; outline: none; text-align: justify; white-space: normal; } .dropdown-content { display: none; position: absolute; background-color: #f1f1f1; min-width: 160px; box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2); z-index: 1; } .dropdown-content a { color: black; padding: 12px 16px; text-decoration: none; display: block; } .dropdown-content a:hover {background-color: #ddd;} .dropdown:hover .dropdown-content {display: block;} .dropdown:hover .dropbtn {background-color: #3e8e41;} .openBtn { display: flex; justify-content: left; } .openButton { border: none; border-radius: 5px; background-color: #1c87c9; color: white; padding: 14px 20px; cursor: pointer; position: fixed; } .loginPopup { position: relative; text-align: center; width: 100%; } .formPopup { display: none; position: fixed; left: 45%; top: 5%; transform: translate(-50%, 5%); border: 3px solid #999999; height: 800px; z-index: 9; } .formContainer { max-width: 300px; max-height: 500px; padding: 5px; background-color: #fff; } .formContainer .btn { padding: 12px 20px; border: none; background-color: #8ebf42; color: #fff; cursor: pointer; width: 100%; margin-bottom: 15px; opacity: 0.8; } .formContainer .cancel { background-color: #cc0000; } .formContainer .btn:hover, .openButton:hover { opacity: 1; } </style>
  7. Scuba diving reservations in Florida, and why can't I even make a reservation in MY timezone and it show like 3 hours difference? It makes no logical sense.... if I make a 6 am reservation myself, it says 3 am lol... mean I'm central, and server is now central.... smh
  8. I'm having an issue with getting my local time to work when filling out a reservation. I am in Central time but it's 3 hours behind the server so when I make the reservation at 6am, my receipt transaction shows 4am. So I decided to make the servertime central time and that works. <?php date_default_timezone_set('America/Chicago'); $timezone = date_default_timezone_get(); echo "Server $timezone"; ?> This sets it now to a server time, at least on the reservation part, to CST, which is what I want, but when I still make a reservation it shows 3am instead of 6 am..... this is the conversion I am using: $time = date("l jS \of F Y h:i:s A", strtotime("$date")) . "\n"; by the way, the above code gives the correct chosen date of their reservation, but time is off. Well since that didn't work I tried this: $time = date("l jS \of F Y h:i:s A", strtotime("$date", "$timezone")) . "\n"; It gives the correct reservation time now, but instead it's PM and not AM and it gives the date Wednesday December 31, 1969 6:00PM (rofl) I hate dealing with time. I just need the timezone of the user so it shows the correct time to them..... So if they are in California, it needs to say 6 am central ti me.... not california time...I don't want them making a 6am reservation and then get a receipt for 3am.... it's confusing.... Any ideas? I've been on this for two days and haven't come up with a solution yet. Geesh, if I can't even get my own time to show Central but 3 hours difference, how can I do anything else? lol I mean if the server is central and I'm central, you would thi nk the reservation time wou ld be central. Thank you
  9. Well, this will disable the submit button, which is fine, I would rather have it hidden, but the issue is that it doesn't enter the information in the database and show the reservation number. UGHHHHH echo"<button type='submit' id='submitbutton' onclick=\"document.getElementById('submitbutton').disabled = true\">Confirm Reservation</button>";
  10. This totally throws my whole format off, so won't work. It takes me to all the components all to the left of the screen and whenI click submit, it takes me back to the regular format with the submit button, which doesn't do anything when you click it, as it should hide, but doesn't. Maybe I wrote that code wrong? echo" <input type='submit' name='submit' id='submit' value='Submit' onclick='this.style.display=\"none\">";
  11. This is so easy, but I have no clue why absolutely nothing works. i've tried php, javascript, jquery and NOTHING is working. For two hours now..... please someone help. This was my last attempt to hide the submit button when I press it. <?php echo" <div id = 'btn'>"; echo" <input type='submit' name='submit' id='btn' value='Submit' />"; echo" </div>"; echo" </form>"; ?> <script> function hideButton(){ document.getElementById('btn').style.display= 'none'; } </script> See, that seems so simple, and it does work when I do the online examples, but it just won't work with me grrrr lol. I have also tried using <?php echo '<p><input type="submit" name="submitted" id="send" value="Send" onclick="this.style.display='none';"></p>'; ?> using it this way of course with how I've written the form: echo" <input type='submit' name='submit' id='submit' value='Submit' onclick='this.style.display='none'; />'";
  12. I decided to go with just one language, as I don't know Javasript well enough. Thank you for your response.
  13. Is it possible to take: $name = $_POST['name']; $email = $_POST['email']; $phone = $_POST['phone']; $divebefore = $_POST['divebefore']; $HowMany = $_POST['party']; $mysqli = new mysqli('localhost', 'root', '', 'scuba'); $stmt = $mysqli->prepare("INSERT INTO bookings (name, email, phone, divebefore, HowMany, date) VALUES (?,?,?,?,?,?)"); $stmt->bind_param('ssssss', $name, $email, $phone, $divebefore, $HowMany, $date); $stmt->execute(); $msg = "<div class='alert alert-success'>Booking Successfull</div>"; $stmt->close(); $mysqli->close(); and then add it to this script if(return_data=='OK'){ $('#display_msg').html('Validation is ok') }else{ reload(); $('#display_msg').html('Validation failed') } $("#display_msg").show(); setTimeout(function() { $("#display_msg").fadeOut('slow'); }, 3000); }); Right after the validation is ok..... With the form button below that would send it. <Form type=post action=captcha-demo-data.php id=f1><input type=text name=t1 id=t1> <img src=captcha-image-adv.php id="capt"><input type=button id='reload' value='Reload image'><input type=button id=b1 value=Submit></form> <div id=display_msg></div> With all of this being on one page. basically I want the sql inserted into the database using javascript when they have the captcha correct.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.