Jump to content

Search the Community

Showing results for tags 'php'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to PHP Freaks
    • Announcements
    • Introductions
  • PHP Coding
    • PHP Coding Help
    • Regex Help
    • Third Party Scripts
    • FAQ/Code Snippet Repository
  • SQL / Database
    • MySQL Help
    • PostgreSQL
    • Microsoft SQL - MSSQL
    • Other RDBMS and SQL dialects
  • Client Side
    • HTML Help
    • CSS Help
    • Javascript Help
    • Other
  • Applications and Frameworks
    • Applications
    • Frameworks
    • Other Libraries
  • Web Server Administration
    • PHP Installation and Configuration
    • Linux
    • Apache HTTP Server
    • Microsoft IIS
    • Other Web Server Software
  • Other
    • Application Design
    • Other Programming Languages
    • Editor Help (PhpStorm, VS Code, etc)
    • Website Critique
    • Beta Test Your Stuff!
  • Freelance, Contracts, Employment, etc.
    • Services Offered
    • Job Offerings
  • General Discussion
    • PHPFreaks.com Website Feedback
    • Miscellaneous

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Age


Donation Link

  1. Hello, I am new to PHP, so I decided the best way to learn is to build a CMS, that I can build and adapt as time progresses. I am wanting to create a setup/install wizard for when a user first uploads the website and then visits the website. I attempted to do this on my own, but it did not work, but hey I still included the code in-case I was close to getting it working. (See below). I am wanting to have a HTML form that will contain the input fields, where the user will enter their database host, username, and password. And all of the details in the form will replace the mysqli connection in the config.php file, which is seperate from the install file. That is all I really need help with at the moment, as creating users, etc is pretty easy (even though I am new to PHP). My "attempted" code: - Install.php: <?php /* Config required to replace the database strings */ require('config/config.php'); /* HTML Form to be echoed for the user */ $form = " <form name='form' action='' method='get'> <input type='text' name='host' placeholder='Database host' /> <input type='text' name='database' placeholder='Database name' /> <input type='text' name='username' placeholder='Database username' /> <input type='password' name='password' placeholder='Database password' /> <input type='submit' name='submit' value='Change values' /> </form> "; /* Echo the form so I can see it */ echo $form; /* Get the results from the HTML Form */ $gethost = $_GET['host']; $getdb = $_GET['database']; $getuser = $_GET['username']; $getpass = $_GET['password']; /* Replace the database connections in config.php */ /* However, does not work :/ */ if (isset($_GET['submit'])) { str_replace($gethost,$host); } ?> - Config.php: <?php $host = "localhost"; $username = "root"; $password = ""; $database = "website"; /* Change this line in the HTML Form in setup.php */ $dbc = mysqli_connect($host, $username, $password, $database); ?> Thanks in advanced, Unique
  2. Hello, I am looking for a php script to import a .Sql file that is in a specific url (like: http://www.dropbox.com/s/xxxx/file.sql) to MySql DB. Thanks
  3. Good evening I hope someone would be so kind as to help me. I am completely new too php oop and I just need help with one tiny problem. I have written some code and I understand most of the concepts concerning oop in php, it's just that I am struggling with interfaces and I don't really see why it should be used if I can just create methods, but anyway I was told it is a good practice to use interfaces because one of the main reasons of oop is to re-use code, So I have implemented an interface but I can call the method with and without the implementation of the interface so I was kind of wondering, what the purpose of interfaces are? or am I doing something wrong?
  4. Someone should please help me with this, i created this login script for Admin and Customer login based on the type of radio button choosed. But i dont knwo what the error is, i always get wrong user name and password but if i register it submit to the database but to login with my details continue to give wrong username and password. I have even tried it on my easyphp server it work fine, but when i uploaded it to the website online, i keep on getting wrong username and passwpord. Please, brother, sisters, friends, senior and whoever can help me you kindly do it. You can send your correct script to me, my email is jimohwareez@gmail.com Below is the script: <?php $username=$_POST['UserName']; $password=$_POST['Password']; $usertype=$_POST['rdType']; if($usertype=="Admin") { $con = mysql_connect("localhost","sample_sample","sample"); mysql_select_db("sample_sample", $con); $sql = "select * from admin_master where txtusername='".$username."' and txtpassword='".$password."'"; $result = mysql_query($sql,$con); $records = mysql_num_rows($result); $row = mysql_fetch_array($result); if ($records==0) { echo '<script type="text/javascript">alert("Wrong UserName or Password");window.location=\'index.php\';</script>'; } else { header("location:blend_sample_details_highvertical/index.php"); } mysql_close($con); } else if($usertype=="Customer") { $con = mysql_connect("localhost","sample_sample","sample"); mysql_select_db("sample_sample", $con); $sql = "select * from customer_registration where UserName='".$username."' and Password='".$password."' "; $result = mysql_query($sql,$con); $records = mysql_num_rows($result); $row = mysql_fetch_array($result); if ($records==0) { echo '<script type="text/javascript">alert("Wrong Username or Password");window.location=\'signin.php\';</script>'; } else { $_SESSION['id']=$row['customerid']; $_SESSION['name']=$row['customername']; header("location:customer/index.php"); } } ?>
  5. <?php $con=mysqli_connect("localhost","my_user","","shazz"); $query = mysqli_query($con,"SELECT * from posts2 order by rand() LIMIT 0,4"); $post_title ="shazz"; while ($row=mysqli_fetch_array($query)) { $post_id=$row['post_id']; $post_title=$row['post_title']; $post_date=$row['post_date']; $post_author=$row['post_author']; $post_image=$row['post_image']; $post_keywords=$row['post_keywords']; $post_content=substr($row['post_content'],0,200); } ?> the following are the errors im facing: Warning: mysqli_connect(): (HY000/1044): Access denied for user ''@'localhost' to database 'shazz' inC:\xampp\htdocs\shazz\include\main_content.php on line 3 Warning: mysqli_query() expects parameter 1 to be mysqli, boolean given inC:\xampp\htdocs\shazz\include\main_content.php on line 4 Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, null given inC:\xampp\htdocs\shazz\include\main_content.php on line 6
  6. Hi, I want to set a variable based on the contents of another variable - I think I've see CASE used for this before but not entirely sure. Basically I'm trying to tidy this up: if ($var1 = "1") { $var2 = "a" } if ($var1 = "2" ) { $var2 = "b" } if ($var1 = "3") { $var2 = "c" } Any help appreciated. Thanks.
  7. Im using excelwriter.inc.php library to write data in XLS. I have a system where I select column names like "id" , "name", "description" etc. This columns can be chosen from list. The column count can vary from choosing 1 or 2 or 40 columns to appear in XLS. As I chose more columns to appear in XLS. The data is not shown in proper format. Some data goes missing in between or with large number of chosen column the count is reduced to 8000-9000 rows. Suppose if column count is around at max 2 . Suppose id , name , the total rows would be perfectly shown having 10k records. But as I increase the column say adding a description . The row count would reduce to suppose 8-9k. Now If I keep increasing more column than The record count keep on decreasing and also some columns data goes missing. There is some problem with the excelwriter library to write data in XLS. LOGIC : One sheet will have maximum 10k rows. If count exceeds 10k . It will generate a new sheet. excelwriter.inc.php
  8. Hello everyone My name is Gary Taylor, I am learning PHP now, getting advance code in PHP now, but still struggle to complete. I hope you will happy to help me to solve my problem in PHP. It is nice to meet you all! Have a great day!
  9. I am trying to display Json data using PHP but I have ran into a problem. This is the json: }, { "node_title": "Room", "Room description": "This is Room 1", "Room name": "Room 1", "Room Type": "Bedroom", "Room attributes": [ ] }, { "node_title": "Room", "Room description": "This is Room 2", "Room name": "Room 2", "Room Type": "Bedroom", "Room attributes": [ This is my PHP: <?php $code = isset($_POST['search']) ? $_POST['search'] : '123nocode123456'; $roomjson = file_get_contents("http://my.json.com/". $code); $roomobj = json_decode($roomjson); ?> <?php echo '<div role="tabpanel"> <ul class="nav nav-tabs" role="tablist"> <li role="presentation" class="active"><a href="#home" aria-controls="home" role="tab" data-toggle="tab">Home</a></li>'; if (empty($roomobj)) { echo '</div>'; }else{ if ($roomobj{0}->{'Room Type'} == 'Bedroom') { echo '<li role="presentation"><a href="#bedroom1" aria-controls="bedroom1" role="tab" data-toggle="tab">'; echo ($roomobj{0}->{'Room name'}); echo '</a></li></div>'; ?> The problem is, I have two json 'nodes' that have the same 'Room Type' value, so how can I differentiate between the two? But I need to display both of them. I think I can use foreach but I need the values 'Room Name' to be in separate <li>.
  10. How do add $_GET['return'] to get output $input['return'] like i have $input['username'] and add value null if no return url detected? <?php $errors = array(); /* Form is not submitted */ $input = array( 'username' => NULL, 'password' => NULL, 'remember' => NULL ); /* Form is submitted */ if(filter_has_var(INPUT_POST, 'submit')){ $defs_POST = array( 'username' => FILTER_SANITIZE_STRING, 'password' => FILTER_UNSAFE_RAW, 'remember' => FILTER_SANITIZE_STRING ); $input = filter_input_array(INPUT_POST, $defs_POST); if(empty($input['username'])){ $errors[] = 'Please enter your username.'; } if(empty($input['password'])){ $errors[] = 'Please enter your password.'; } } if(filter_has_var(INPUT_POST, 'submit') and empty($errors)){ print "Username = '".$input['username']."', Password = '".$input['password']."', Remember = '".$input['remember']."', Return = '".$input['return']."'"; /* if(!empty($input['return'])) redirect(urldecode($input['return'])); else redirect('index.php?do=home'); */ } print " <form method='post'> Username <input type='text' name='username' value='".$input['username']."'><br> Password <input type='text' name='password' value='".$input['password']."'><br> Remember me <input type='checkbox' name='remember' value='Yes'><br> <input type='submit' name='submit' value='SUBMIT'> </form>"; ?>
  11. I've created a php code that automatically pulls post that are assigned to a category (dailydose) from my wordpress site and creates a daily mailchimp campaign using a email template. I now want to be able to pull ads that are assiocated with each post. So I'm stuck on how I can make that happen please help!! functions.php //wp_schedule_event( 1428610800, 'hourly', 'daily_dose_mailer' ); //wp_unschedule_event( time(), 'hourly', 'daily_dose_mailer' ); //wp_clear_scheduled_hook( 'daily_dose_mailer' ); add_action( 'daily_dose_mailer', 'daily_doser' ); function daily_doser(){ $cur_day = date( "w", time()); $standard_order = array("1","2","3","4","5"); if($cur_day >= 1 && $cur_day <= 5){ require_once 'includes/mailchimp-mailchimp-api-php-190cf58000ee/src/Mailchimp.php'; //Get content $custom_query = new WP_Query(array('post_type'=>'post','posts_per_page'=>5,'cat'=>1279)); $content = array(); $std_count = 0; while($custom_query->have_posts()) : $custom_query->the_post(); $image = wp_get_attachment_image_src( get_post_thumbnail_id( get_the_ID() ), 'single-post-thumbnail' ); if(get_post_meta(get_the_ID(),"dd_order",true) != "") $content[get_post_meta(get_the_ID(),"dd_order",true)] = array("title"=>get_the_title(),"summary"=>get_the_excerpt(),"link"=>get_permalink(),"image"=>$image[0]); else $content[$standard_order[$std_count]] = array("title"=>get_the_title(),"summary"=>get_the_excerpt(),"link"=>get_permalink(),"image"=>$image[0]); $std_count++; endwhile; $content_with_html = ''; $count = 1; $ad_count = 0; if($cur_day == 1) $ad_order = array("4","5","6","7","8"); if($cur_day == 2) $ad_order = array("8","4","5","6","7"); if($cur_day == 3) $ad_order = array("7","8","4","5","6"); if($cur_day == 4) $ad_order = array("6","7","8","4","5"); if($cur_day == 5) $ad_order = array("5","6","7","8","4"); foreach($content as $cont){ if(function_exists("wp_template_ad")) { $ad = wp_template_ad($ad_order[$ad_count]); } if($count == 1){ $content_with_html .= ' <tr> <td> <table style="width: 600px; margin: 10px 0;" width="600px"> <tbody> <tr> <td style="padding: 0px 0;"> <a href="'.$content[strval($count)]["link"].'" style="border-collapse: collapse; display: block; font-family: Arial Black, Gadget, sans-serif; font-weight: 900; font-size: 26px; line-height: 28px; color: #03030B; letter-spacing: -.03em; text-decoration: none;">'.$content[strval($count)]["title"].'</a> <a href="'.$content[strval($count)]["link"].'" style="text-decoration: none;float:right;" target="_blank"><img src="'.$content[strval($count)]["image"].'" style="width: 250px; min-height: 165px;" width="250" width="250" /></a> <p style="line-height: 18px; font-size: 12px; font-family: Georgia; margin: 0; padding: 0;"> <span style="font-size: 15px; line-height: 19px;">'.$content[strval($count)]["summary"].'</span><br><a href="'.$content[strval($count)]["link"].'" style="font-size: 14px; text-decoration: none; font-weight: bold; font-family: Arial Black, Gadget, sans-serif; color: #da1f3e;" target="_blank">READ MORE</a></p> </td> </tr> </tbody> </table> </td> </tr> <tr align="center"> <td bgcolor="#f3f3f3" style="background-color: #f3f3f3;"> '.$ad.'</td> </tr> <tr> <td> <img alt="" src="http://dsnews.com/wp-content/uploads/sites/25/2014/01/Solid-Line.jpg" style="display: block; border: 0px solid; text-align: center; width: 600px; min-height: 9px;" width="600" width="600" /> <!--AD GOES HERE--> <img alt="" src="http://dsnews.com/wp-content/uploads/sites/25/2014/01/Solid-Line.jpg" style="display: block; border: 0px solid; text-align: center; width: 600px; min-height: 9px;" width="600" width="600" /></td> </tr> '; }else{ $content_with_html .= ' <tr> <td style="padding: 13px 0;"> <a href="'.$content[strval($count)]["link"].'" style="border-collapse: collapse; display: block; font-family: Arial Black, Gadget, sans-serif; font-weight: 900; font-size: 20px; line-height: 24px; color: #03030B; letter-spacing: -.03em; text-decoration: inherit;">'.$content[strval($count)]["title"].'</a> <p style="line-height: 18px; font-size: 12px; font-family: Georgia; margin: 0; padding: 0;"> <span style="font-size: 12px; line-height: 18px;">'.$content[strval($count)]["summary"].'</span><br><a href="'.$content[strval($count)]["link"].'" style="font-size: 11px; text-decoration: none; font-weight: bold; font-family: Arial Black, Gadget, sans-serif; color: #da1f3e;" target="_blank">READ MORE</a></p> </td> </tr> <tr align="center"> <td bgcolor="#f3f3f3" style="background-color: #f3f3f3;"> '.$ad.'</td> </tr> <tr> <td> <img alt="" src="http://dsnews.com/wp-content/uploads/sites/25/2014/01/Solid-Line.jpg" style="display: block; border: 0px solid; text-align: center; width: 600px; min-height: 9px;" width="600" width="600" /> <!--AD GOES HERE--> <img alt="" src="http://dsnews.com/wp-content/uploads/sites/25/2014/01/Solid-Line.jpg" style="display: block; border: 0px solid; text-align: center; width: 600px; min-height: 9px;" width="600" width="600" /></td> </tr> '; } $count++; $ad_count++; } /*$content_with_html .= ' <tr align="center"> <td class="spacer"> '. wp_templol($ad_order[$ad_count]).'</td> </tr> ';*/ $MC = new Mailchimp('01a1ecf38bc12fdc975ff0c569945244-us1'); //Pseudo code //Grab the list that it will be sent to //lists/members (string apikey, string id, string status, struct opts) //Create markup of email - this also assigns the appropriate list //campaigns/create (string apikey, string type, struct options, struct content, struct segment_opts, struct type_opts) $retval = $MC->call('campaigns/create', array( "type"=>"regular", "options"=> array("list_id"=>"1924082bfe", "subject"=>"Your Daily Dose from DS News", "from_name"=>"DSNews", "from_email"=>"news@dsnews.com", "inline_css"=>true), "content"=> array("html"=>' <!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> <title>Your Daily Dose of DS News</title> </head> <body> <div align="left" style="text-align: left; font-size: 12px; font-family: Century Gothic,Georgia,Verdana; padding-bottom: 50px !important;"> <table border="0" cellpadding="0" cellspacing="0" style="width: 100%; margin: 0px;" width="728"> <tbody> <tr> <td align="center" bgcolor="#fff" colspan="2" style="padding: 5px; text-align: center;"> Email not displaying correctly? <a href="*|ARCHIVE|*">Display this email in your browser</a></td> </tr> <tr> <td align="center" bgcolor="#000" colspan="2" style="text-align: center; background-color: #000;"> <img alt="" height="30" src="http://admin.dsnews.com/editor_images/image_19b6f173/column.gif" style="width: 15px; min-height: 30px;" width="15" width="15" /> <table align="center" bgcolor="#000000" border="0" cellpadding="0" cellspacing="10px" width="600"> <tbody> <tr align="center" style="width: 600px;"> <td align="center" bgcolor="#FFF" style="padding: 0 0px; font-size: 12px; text-transform: uppercase; text-align: left; font-weight: bold; color: #fe0000; background-color: #000; font-family: Arial, Helvetica, sans-serif;"> *|DATE:l, M j, Y|*</td> <td align="right" bgcolor="#8a8b8a" style="font-size: 12px; text-transform: uppercase; padding: 0 0px; text-align: right; font-weight: bold; color: #fff; background-color: #000;"> <a href="http://link.dsnews.com/c/443/75a98e997857ea44b0bc30da975bb0f12b9e4c97445e247987c4a6efb818978c" style="font-size: 12px; text-decoration: none; text-align: right; font-family: Arial Black, Gadget, sans-serif; color: #fff; background-color: #000; letter-spacing: .003em;" target="_blank">HOME</a> | <a href="http://link.dsnews.com/c/443/75a98e997857ea44b0bc30da975bb0f12b9e4c97445e24791b911a59d15e5063" style="font-size: 12px; text-decoration: none; text-align: right; font-family: Arial Black, Gadget, sans-serif; color: #fff; background-color: #000;" target="_blank">CONTACT US</a> | <a href="http://link.dsnews.com/c/443/75a98e997857ea44b0bc30da975bb0f12b9e4c97445e2479f018cfa44911db10" style="font-size: 12px; text-decoration: none; text-align: right; font-family: Arial Black, Gadget, sans-serif; color: #fff; background-color: #000;" target="_blank">MAGAZINE</a><a href="http://link.dsnews.com/c/443/75a98e997857ea44b0bc30da975bb0f12b9e4c97445e2479c6b1632e3f8df548" style="text-decoration: none; color: #000;" target="_blank"> </a>| <em><a href="http://link.dsnews.com/c/443/75a98e997857ea44b0bc30da975bb0f12b9e4c97445e2479ac6f4a1f6d5178c8" style="font-size: 12px; text-decoration: none; text-align: right; font-family: Arial Black, Gadget, sans-serif; color: #fff; background-color: #000;" target="_blank">SUBSCRIBE</a></em></td> </tr> </tbody> </table> </td> </tr> </tbody> </table> <table align="center" border="0" cellpadding="0" cellspacing="0" style="width: 600px; margin: 0px auto;"> <tbody> <tr> <td width="600"> <div align="center" style="text-align: center;"> </div> <a href="http://link.dsnews.com/c/443/75a98e997857ea44b0bc30da975bb0f12b9e4c97445e2479b35fafb4d42723f5" style="text-decoration: none;" target="_blank"><img alt="DSNews.com | Daily Dose" height="109" src="http://dsnews.com/wp-content/uploads/sites/25/2014/01/Daily-Dose.jpg" style="display: block; border: 0px solid; text-align: center; width: 600px; min-height: 123px;" width="600" width="600" /></a></td> </tr> <tr> <td> <div align="center" style="text-align: center;"> </div> <img alt="" src="http://dsnews.com/wp-content/uploads/sites/25/2014/01/Solid-Line.jpg" style="display: block; border: 0px solid; text-align: center; width: 600px; min-height: 9px;" width="600" width="600" /></td> </tr> <tr> <td> <table style="width: 600px; margin: 0;"> <tbody> <tr> <td align="center" style="padding: 0px 0; text-align: center;"> <a href="http://link.dsnews.com/c/443/75a98e997857ea44b0bc30da975bb0f12b9e4c97445e24799b979aa344545f8a" style="border-collapse: collapse; font-family: Arial Black, Gadget, sans-serif; font-size: 10px; color: #03030B; letter-spacing: -.003em; text-decoration: none;"> DSNEWS.COM</a> | <a href="http://link.dsnews.com/c/443/75a98e997857ea44b0bc30da975bb0f12b9e4c97445e2479db831868790c2639" style="border-collapse: collapse; font-family: Arial Black, Gadget, sans-serif; font-size: 10px; color: #03030B; letter-spacing: -.003em; text-decoration: inherit;">REOREDBOOK</a>| <a href="http://link.dsnews.com/c/443/75a98e997857ea44b0bc30da975bb0f12b9e4c97445e2479d269f0e3591d670f" style="border-collapse: collapse; font-family: Arial Black, Gadget, sans-serif; font-size: 10px; color: #03030B; letter-spacing: -0.03em; text-decoration: inherit;">BLACK BOOK</a> | <a href="http://link.dsnews.com/c/443/75a98e997857ea44b0bc30da975bb0f12b9e4c97445e247903105127fafb9dbc" style="border-collapse: collapse; font-family: Arial Black, Gadget, sans-serif; font-size: 10px; color: #03030B; letter-spacing: -.003em; text-decoration: inherit;">FORCE</a> | <a href="http://link.dsnews.com/c/443/75a98e997857ea44b0bc30da975bb0f12b9e4c97445e247907d4c0d59b488676" style="border-collapse: collapse; font-family: Arial Black, Gadget, sans-serif; font-size: 10px; color: #03030B; letter-spacing: -.003em; text-decoration: inherit;">GOVERNMENT FORUM</a> | <a href="http://link.dsnews.com/c/443/75a98e997857ea44b0bc30da975bb0f12b9e4c97445e247905ea889cdfee43cf" style="border-collapse: collapse; font-family: Arial Black, Gadget, sans-serif; font-size: 10px; color: #03030B; letter-spacing: -.003em; text-decoration: inherit;">FIVE STAR CONFERENCE</a></td> </tr> </tbody> </table> </td> </tr> <tr> <td> <img alt="" src="http://dsnews.com/wp-content/uploads/sites/25/2014/01/Solid-Line.jpg" style="display: block; border: 0px solid; text-align: center; width: 600px; min-height: 9px;" width="600" width="600" /></td> </tr> '.$content_with_html.' <tr> <td> </td> </tr> </tbody> </table> <table bgcolor="#f3f3f3" border="0" cellpadding="0" cellspacing="0" style="margin: 10px auto;" width="100%"> <tbody> <tr> <td> <table align="center" border="0" cellpadding="0" cellspacing="0" width="600"> <tbody> <tr> <td colspan="2"> <table style="width: 600px; margin: 10px auto;"> <tbody> <tr> <td align="center" style="width: 200px; text-align: center; padding-right: 5px;"> <a href="http://link.dsnews.com/c/443/75a98e997857ea44b0bc30da975bb0f12b9e4c97445e24793af4e6a183b3ef6f" style="font-size: 9px; text-decoration: none; color: #8a8b8a;" target="_blank"><img alt="DSNews" height="50" src="http://dsnews.com/wp-content/uploads/sites/25/2014/01/ds.jpg" width="50" /></a></td> </tr> </tbody> </table> </td> </tr> <tr> <td align="center" style="font-size: 9px; text-align: left; color: #8a8b8a; border-top-color: #000; padding: 10px 0; border-top-style: groove; border-top-width: 2px;" width="280"> <strong style="color: #67c7d3; font-weight: normal;">Corporate Offices</strong> | Phone: 800.856.8060<br /> 1909 Woodall Rodgers, Suite 300 Dallas, Texas 75201</td> <td align="center" style="font-size: 9px; text-align: right; color: #8a8b8a; border-top-color: #000; padding: 10px 0; border-top-style: groove; border-top-width: 2px;" width="320"> <strong style="color: #67c7d3; font-weight: normal;">Washington Bureau</strong> | Phone: 202.393.5511<br /> 1101 Pennsylvania Ave. NW, Suite 600 | Washington, D.C. 20004</td> </tr> </tbody> </table> <table align="center" border="0" cellpadding="0" cellspacing="0" width="600"> <tbody> <tr> <td align="center" colspan="2" style="color: #8a8b8a; padding: 10px 0px; font-size: 7px; border-bottom-width: 1px; border-bottom-style: dotted; border-bottom-color: #252722; text-align: center;"> You are receiving this e-mail because you opted in at our Web site DSNews.com or attended a Five Star Conference. Copyright 2009 DS News. All rights reserved.<br /> <a href="*|UNSUB|*" style="text-decoration: none; color: #000000; " target="_blank">Unsubscribe.</a> <span style="line-height: 11.199999809265137px;">*|EMAIL|*<span style="font-size: 7px; line-height: 1.6em;"> from this list.</span></span></td> </tr> <tr> <td align="center" colspan="2"> <table style="width: 600px;"> <tbody> <tr> <td align="center" style="text-align: center;"> <a href="http://link.dsnews.com/c/443/75a98e997857ea44b0bc30da975bb0f12b9e4c97445e247963cf5f9844f5a817" style="font-size: 9px; text-decoration: none; color: #8a8b8a;" target="_blank">DSNews.com</a></td> <td align="center" style="text-align: center;"> <a href="http://link.dsnews.com/c/443/75a98e997857ea44b0bc30da975bb0f12b9e4c97445e2479c36851c1fe0a7a08" style="font-size: 9px; text-decoration: none; color: #8a8b8a;" target="_blank">REORedBook</a></td> <td align="center" style="text-align: center;"> <a href="http://link.dsnews.com/c/443/75a98e997857ea44b0bc30da975bb0f12b9e4c97445e2479f47338dd7e641363" style="font-size: 9px; text-decoration: none; color: #8a8b8a;" target="_blank">BlackBook</a></td> <td align="center" style="text-align: center;"> <a href="http://link.dsnews.com/c/443/75a98e997857ea44b0bc30da975bb0f12b9e4c97445e2479b6f3467ce75a656b" style="font-size: 9px; text-decoration: none; color: #8a8b8a;" target="_blank">TheFiveStar.com</a></td> <td align="center" style="text-align: center;"> <a href="http://link.dsnews.com/c/443/75a98e997857ea44b0bc30da975bb0f12b9e4c97445e24790cdf2f599aba04c2" style="font-size: 9px; text-decoration: none; color: #8a8b8a;" target="_blank">FORCE</a></td> </tr> </tbody> </table> </td> </tr> </tbody> </table> </td> </tr> </tbody> </table> </div> <br /> </body> </html> ') ) ); //Send it out //campaigns/send-test (string apikey, string cid, array test_emails, string send_type) - this will be replace by normal send // echo $retval; } }
  12. I want to be able to check whether values exist in the php array without having to click the submit button to do those checks using jquery/ajax. when users enter an abbreviation in the text field want to be able to show that the brand exists (either vw or tyta) or not (as they type in the input box) and show the results in the carnamestatus div. I was following a tutorial from youtube, however it queried against a mysql database. I was wondering if this is possible using php arrays instead of mysql? I would be grateful if you could pick any faults in the code. The jquery is in the head section. the rest of the code is as follows: <?php $car = array() $car["vw"] = array( "name" => "volkswagen"); $car["tyta"] = array( "name => "toyota"); ?> the html code is as follows: <label for="carname">Car Code:</label> <input type="text" onblur="checkcar()" value="" id="carname" /> <div id="carnamestatus"></div> the checkcar() function checkcar(){ var u = _("carname").value; if(u != ""){ _("carname").innerHTML = 'checking ...'; var B = new XMLHttpRequest(); B.open("POST","check.php",true); / B.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); B.onreadystatechange = function() { if(B.readyState==4 && B.status== 200) { _("carnamestatus").innerHTML = B.responseText; } } var v = "carnamecheck="+u; B.send(v); } } </script>
  13. Login page: <?php require_once('Connections/localhost.php'); ?> <?php if (!function_exists("GetSQLValueString")) { function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { if (PHP_VERSION < 6) { $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue; } $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue); switch ($theType) { case "text": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "long": case "int": $theValue = ($theValue != "") ? intval($theValue) : "NULL"; break; case "double": $theValue = ($theValue != "") ? doubleval($theValue) : "NULL"; break; case "date": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "defined": $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; break; } return $theValue; } } ?> <?php // *** Validate request to login to this site. if (!isset($_SESSION)) { session_start(); } $loginFormAction = $_SERVER['PHP_SELF']; if (isset($_GET['accesscheck'])) { $_SESSION['PrevUrl'] = $_GET['accesscheck']; } if (isset($_POST['username'])) { $loginUsername=$_POST['username']; $password=$_POST['password']; $MM_fldUserAuthorization = ""; $MM_redirectLoginSuccess = "controlpanel.php"; $MM_redirectLoginFailed = "login.php"; $MM_redirecttoReferrer = false; mysql_select_db($database_localhost, $localhost); $LoginRS__query=sprintf("SELECT username, password FROM users WHERE username=%s AND password=%s", GetSQLValueString($loginUsername, "text"), GetSQLValueString($password, "text")); $LoginRS = mysql_query($LoginRS__query, $localhost) or die(mysql_error()); $loginFoundUser = mysql_num_rows($LoginRS); if ($loginFoundUser) { $loginStrGroup = ""; if (PHP_VERSION >= 5.1) {session_regenerate_id(true);} else {session_regenerate_id();} //declare two session variables and assign them $_SESSION['MM_Username'] = $loginUsername; $_SESSION['MM_UserGroup'] = $loginStrGroup; if (isset($_SESSION['PrevUrl']) && false) { $MM_redirectLoginSuccess = $_SESSION['PrevUrl']; } header("Location: " . $MM_redirectLoginSuccess ); } else { header("Location: ". $MM_redirectLoginFailed ); } } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "[url=http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd]http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">[/url] <html xmlns="[url=http://www.w3.org/1999/xhtml]http://www.w3.org/1999/xhtml">[/url] <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>Untitled Document</title> <script src="SpryAssets/SpryValidationTextField.js" type="text/javascript"></script> <link href="SpryAssets/SpryValidationTextField.css" rel="stylesheet" type="text/css" /> </head> <body><form action="<?php echo $loginFormAction; ?>" method="POST" id="loginform"><table width="600" border="0"> <tr> <td><span id="sprytextfield1">username<br /> <label for="username"></label> <input type="text" name="username" id="username" /> <span class="textfieldRequiredMsg">A value is required.</span></span></td> </tr> <tr> <td> </td> </tr> <tr> <td><span id="sprytextfield2">password<br /> <label for="password"></label> <input type="password" name="password" id="password" /> <span class="textfieldRequiredMsg">A value is required.</span></span></td> </tr> <tr> <td> </td> </tr> <tr> <td><input type="submit" name="login" id="login" value="login" /></td> </tr> <tr> <td> </td> </tr> </table> </form> <script type="text/javascript"> var sprytextfield1 = new Spry.Widget.ValidationTextField("sprytextfield1"); var sprytextfield2 = new Spry.Widget.ValidationTextField("sprytextfield2"); </script> </body> </html> Control panel: <?php require_once('Connections/localhost.php'); ?> <?php if (!isset($_SESSION)) { session_start(); } $MM_authorizedUsers = ""; $MM_donotCheckaccess = "true"; // *** Restrict Access To Page: Grant or deny access to this page function isAuthorized($strUsers, $strGroups, $UserName, $UserGroup) { // For security, start by assuming the visitor is NOT authorized. $isValid = False; // When a visitor has logged into this site, the Session variable MM_Username set equal to their username. // Therefore, we know that a user is NOT logged in if that Session variable is blank. if (!empty($UserName)) { // Besides being logged in, you may restrict access to only certain users based on an ID established when they login. // Parse the strings into arrays. $arrUsers = Explode(",", $strUsers); $arrGroups = Explode(",", $strGroups); if (in_array($UserName, $arrUsers)) { $isValid = true; } // Or, you may restrict access to only certain users based on their username. if (in_array($UserGroup, $arrGroups)) { $isValid = true; } if (($strUsers == "") && true) { $isValid = true; } } return $isValid; } $MM_restrictGoTo = "login.php"; if (!((isset($_SESSION['MM_Username'])) && (isAuthorized("",$MM_authorizedUsers, $_SESSION['MM_Username'], $_SESSION['MM_UserGroup'])))) { $MM_qsChar = "?"; $MM_referrer = $_SERVER['PHP_SELF']; if (strpos($MM_restrictGoTo, "?")) $MM_qsChar = "&"; if (isset($_SERVER['QUERY_STRING']) && strlen($_SERVER['QUERY_STRING']) > 0) $MM_referrer .= "?" . $_SERVER['QUERY_STRING']; $MM_restrictGoTo = $MM_restrictGoTo. $MM_qsChar . "accesscheck=" . urlencode($MM_referrer); header("Location: ". $MM_restrictGoTo); exit; } ?> <?php if (!function_exists("GetSQLValueString")) { function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { if (PHP_VERSION < 6) { $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue; } $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue); switch ($theType) { case "text": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "long": case "int": $theValue = ($theValue != "") ? intval($theValue) : "NULL"; break; case "double": $theValue = ($theValue != "") ? doubleval($theValue) : "NULL"; break; case "date": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "defined": $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; break; } return $theValue; } }if (!function_exists("GetSQLValueString")) { function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { if (PHP_VERSION < 6) { $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue; } $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue); switch ($theType) { case "text": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "long": case "int": $theValue = ($theValue != "") ? intval($theValue) : "NULL"; break; case "double": $theValue = ($theValue != "") ? doubleval($theValue) : "NULL"; break; case "date": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "defined": $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; break; } return $theValue; } } $colname_user = "-1"; if (isset($_SESSION['username'])) { $colname_user = $_SESSION['username']; } mysql_select_db($database_localhost, $localhost); $query_user = sprintf("SELECT * FROM users WHERE username = %s", GetSQLValueString($colname_user, "text")); $user = mysql_query($query_user, $localhost) or die(mysql_error()); $row_user = mysql_fetch_assoc($user); $totalRows_user = mysql_num_rows($user);$username_user = "-1"; if (isset($_SESSION['username'])) { $username_user = $_SESSION['username']; } mysql_select_db($database_localhost, $localhost); $query_user = sprintf("SELECT * FROM users WHERE %s = %s", GetSQLValueString($username_user, "text"),GetSQLValueString($username_user, "text")); $user = mysql_query($query_user, $localhost) or die(mysql_error()); $row_user = mysql_fetch_assoc($user); $totalRows_user = mysql_num_rows($user); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "[url=http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd]http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">[/url] <html xmlns="[url=http://www.w3.org/1999/xhtml]http://www.w3.org/1999/xhtml">[/url] <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>Untitled Document</title> </head> <body> <a href="logout.php">logout</a> | <a href="user_epdate.php?username=<?php echo $row_user['username']; ?>">update</a> </body> </html> <?php mysql_free_result($user); ?> User update: <?php require_once('Connections/localhost.php'); ?> <?php if (!isset($_SESSION)) { session_start(); } $MM_authorizedUsers = ""; $MM_donotCheckaccess = "true"; // *** Restrict Access To Page: Grant or deny access to this page function isAuthorized($strUsers, $strGroups, $UserName, $UserGroup) { // For security, start by assuming the visitor is NOT authorized. $isValid = False; // When a visitor has logged into this site, the Session variable MM_Username set equal to their username. // Therefore, we know that a user is NOT logged in if that Session variable is blank. if (!empty($UserName)) { // Besides being logged in, you may restrict access to only certain users based on an ID established when they login. // Parse the strings into arrays. $arrUsers = Explode(",", $strUsers); $arrGroups = Explode(",", $strGroups); if (in_array($UserName, $arrUsers)) { $isValid = true; } // Or, you may restrict access to only certain users based on their username. if (in_array($UserGroup, $arrGroups)) { $isValid = true; } if (($strUsers == "") && true) { $isValid = true; } } return $isValid; } $MM_restrictGoTo = "login.php"; if (!((isset($_SESSION['MM_Username'])) && (isAuthorized("",$MM_authorizedUsers, $_SESSION['MM_Username'], $_SESSION['MM_UserGroup'])))) { $MM_qsChar = "?"; $MM_referrer = $_SERVER['PHP_SELF']; if (strpos($MM_restrictGoTo, "?")) $MM_qsChar = "&"; if (isset($_SERVER['QUERY_STRING']) && strlen($_SERVER['QUERY_STRING']) > 0) $MM_referrer .= "?" . $_SERVER['QUERY_STRING']; $MM_restrictGoTo = $MM_restrictGoTo. $MM_qsChar . "accesscheck=" . urlencode($MM_referrer); header("Location: ". $MM_restrictGoTo); exit; } ?> <?php if (!function_exists("GetSQLValueString")) { function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { if (PHP_VERSION < 6) { $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue; } $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue); switch ($theType) { case "text": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "long": case "int": $theValue = ($theValue != "") ? intval($theValue) : "NULL"; break; case "double": $theValue = ($theValue != "") ? doubleval($theValue) : "NULL"; break; case "date": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "defined": $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; break; } return $theValue; } } $editFormAction = $_SERVER['PHP_SELF']; if (isset($_SERVER['QUERY_STRING'])) { $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']); } if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "signup")) { $updateSQL = sprintf("UPDATE users SET firstname=%s, lastname=%s, email=%s, username=%s, password=%s WHERE userid=%s", GetSQLValueString($_POST['firstname'], "text"), GetSQLValueString($_POST['lastname'], "text"), GetSQLValueString($_POST['email'], "text"), GetSQLValueString($_POST['username'], "text"), GetSQLValueString($_POST['password'], "text"), GetSQLValueString($_POST['userid'], "int")); mysql_select_db($database_localhost, $localhost); $Result1 = mysql_query($updateSQL, $localhost) or die(mysql_error()); $updateGoTo = "controlpanel.php"; if (isset($_SERVER['QUERY_STRING'])) { $updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?"; $updateGoTo .= $_SERVER['QUERY_STRING']; } header(sprintf("Location: %s", $updateGoTo)); } $colname_Recordset1 = "-1"; if (isset($_GET['username'])) { $colname_Recordset1 = $_GET['username']; } mysql_select_db($database_localhost, $localhost); $query_Recordset1 = sprintf("SELECT * FROM users WHERE username = %s", GetSQLValueString($colname_Recordset1, "text")); $Recordset1 = mysql_query($query_Recordset1, $localhost) or die(mysql_error()); $row_Recordset1 = mysql_fetch_assoc($Recordset1); $totalRows_Recordset1 = mysql_num_rows($Recordset1); $username_Recordset1 = "-1"; if (isset($_GET['username'])) { $username_Recordset1 = $_GET['username']; } mysql_select_db($database_localhost, $localhost); $query_Recordset1 = sprintf("SELECT * FROM users WHERE %s = %s", GetSQLValueString($username_Recordset1, "text"),GetSQLValueString($username_Recordset1, "text")); $Recordset1 = mysql_query($query_Recordset1, $localhost) or die(mysql_error()); $row_Recordset1 = mysql_fetch_assoc($Recordset1); $totalRows_Recordset1 = "%"; if (isset($_GET['username'])) { $totalRows_Recordset1 = $_GET['username']; } $colname_registeruser = "-1"; if (isset($_GET['username'])) { $colname_registeruser = $_GET['username']; } mysql_select_db($database_localhost, $localhost); $query_registeruser = sprintf("SELECT userid, firstname, lastname, email, username, password FROM users WHERE username = %s", GetSQLValueString($colname_registeruser, "text")); $registeruser = mysql_query($query_registeruser, $localhost) or die(mysql_error()); $row_registeruser = mysql_fetch_assoc($registeruser); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "[url=http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd]http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">[/url] <html xmlns="[url=http://www.w3.org/1999/xhtml]http://www.w3.org/1999/xhtml">[/url] <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>Untitled Document</title> <script src="SpryAssets/SpryValidationTextField.js" type="text/javascript"></script> <link href="SpryAssets/SpryValidationTextField.css" rel="stylesheet" type="text/css" /> </head> <body><form action="<?php echo $editFormAction; ?>" method="POST" name="signup" id="signup"><table width="600" border="0"> <tr> <td><span id="sprytextfield1">username<br /> <label for="username"></label> <input name="username" type="text" id="username" value="<?php echo $row_registeruser['username']; ?>" /> <span class="textfieldRequiredMsg">A value is required.</span></span></td> </tr> <tr> <td> </td> </tr> <tr> <td><span id="sprytextfield2">password<br /> <label for="password"></label> <input name="password" type="text" id="password" value="<?php echo $row_registeruser['password']; ?>" /> <span class="textfieldRequiredMsg">A value is required.</span></span></td> </tr> <tr> <td> </td> </tr> <tr> <td><span id="sprytextfield3">firstname<br /> <label for="firstname"></label> <input name="firstname" type="text" id="firstname" value="<?php echo $row_registeruser['firstname']; ?>" /> <span class="textfieldRequiredMsg">A value is required.</span></span></td> </tr> <tr> <td> </td> </tr> <tr> <td><span id="sprytextfield4">lastname<br /> <label for="lastname"></label> <input name="lastname" type="text" id="lastname" value="<?php echo $row_registeruser['lastname']; ?>" /> <span class="textfieldRequiredMsg">A value is required.</span></span></td> </tr> <tr> <td> </td> </tr> <tr> <td><span id="sprytextfield5">email<br /> <label for="email"></label> <input name="email" type="text" id="email" value="<?php echo $row_registeruser['email']; ?>" /> <span class="textfieldRequiredMsg">A value is required.</span></span></td> </tr> <tr> <td> </td> </tr> <tr> <td><input type="submit" name="submit" id="submit" value="Submit" /></td> </tr> <tr> <td><input name="userid" type="hidden" id="userid" value="<?php echo $row_registeruser['userid']; ?>" /></td> </tr> </table> <input type="hidden" name="MM_update" value="signup" /> </form> <script type="text/javascript"> var sprytextfield1 = new Spry.Widget.ValidationTextField("sprytextfield1"); var sprytextfield2 = new Spry.Widget.ValidationTextField("sprytextfield2"); var sprytextfield3 = new Spry.Widget.ValidationTextField("sprytextfield3"); var sprytextfield4 = new Spry.Widget.ValidationTextField("sprytextfield4"); var sprytextfield5 = new Spry.Widget.ValidationTextField("sprytextfield5"); </script> </body> </html> <?php mysql_free_result($Recordset1); ?> Please help. I am new to php and i am trying to get a session variable working. I am using dreamweaver cs6. I have got the login page working fine and connecting to my database. THis then loads the control panel,working fine. When i click edit on the control panel it is supposed to take me to a templated page with the session variable for the user logged in, this is not happening it is going to the username on the top row of my database.
  14. Hello, I am using zend pagination in my gallery and its unfortunetly not working right for me. When using tags and search box in gallery -> next/another page is returning with no taging/searching It should look like gallery\page\2\?s=&tag=9 but instead i have gallery\page\2 What can I do about that? 'gallery' => array( 'type' => 'Segment', 'options' => array( 'route' => '/generator_nowy/gallery[/page/:page/]', 'defaults' => array( 'controller' => 'Men\Controller\FrontController', 'action' => 'gallery', 'page' => 1, ) ), 'may_terminate' => true ),
  15. I got this piece of code from a free template and I followed all the instructions that came with it, everything seems fine but mail doesn't go trough. HTML: <!--Start Contact form --> <form name="enq" method="post" action="email/" onsubmit="return validation();"> <fieldset> <input type="text" name="name" id="name" value="" class="input-block-level" placeholder="Name.." /> <input type="text" name="email" id="email" value="" class="input-block-level" placeholder="Email.." /> <textarea rows="11" name="message" id="message" class="input-block-level" placeholder="Message.."></textarea> <div class="actions"> <input type="submit" value="Send!" name="submit" id="submitButton" class="btn btn-info pull-right" title="Send!" /> </div> </fieldset> </form> <!--End Contact form --> PHP: <?php if(isset($_POST['submit'])) { $name = $_POST['name']; $email = $_POST['email']; $query = $_POST['message']; $email_from = $name.'<'.$email.'>'; $to="email@sample.com"; $subject="Enquiry!"; $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; $headers .= "From: ".$email_from."\r\n"; $message=" Name: $name <br> Email-Id: $email <br> Message: $query "; if(mail($to,$subject,$message,$headers)) header("Location:../contact.php?msg=Successful Submission! Thankyou for contacting us."); else header("Location:../contact.php?msg=Error To send Email !"); //contact:-your-email@your-domain.com } ?> JavaScript function validation() { var contactname=document.enq.name.value; var name_exp=/^[A-Za-z\s]+$/; if(contactname=='') { alert("Name Field Should Not Be Empty!"); document.enq.name.focus(); return false; } else if(!contactname.match(name_exp)) { alert("Invalid Name field!"); document.enq.name.focus(); return false; } var email=document.enq.email.value; //var email_exp=/^[A-Za-z0-9\.-_\$]+@[A-Za-z]+\.[a-z]{2,4}$/; var email_exp=/^\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/; if(email=='') { alert("Please Enter Email-Id!"); document.enq.email.focus(); return false; } else if(!email.match(email_exp)) { alert("Invalid Email ID !"); document.enq.email.focus(); return false; } var message=document.enq.message.value; if(message=='') { alert("Query Field Should Not Be Empty!"); document.enq.message.focus(); return false; } return true; } I don't get any errors but mail doesn't simply go trough, checked spam etc.
  16. I looked at a tutorial on youtube to make a blog. I need to be connected after logging in my admin login with the admin panel. What is my mistake here? Thank you very much! index.php <?php include_once "../blog/connect.php"; include_once "../blog/functie.php"; ?> <!doctype html> <html lang="en"> <head> <meta charset="utf-8"/> <title>Dashboard I Admin Panel</title> <link rel="stylesheet" href="css/layout.css" type="text/css" media="screen" /> <!--[if lt IE 9]> <link rel="stylesheet" href="css/ie.css" type="text/css" media="screen" /> <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script> <![endif]--> <script src="js/jquery-1.5.2.min.js" type="text/javascript"></script> <script src="js/hideshow.js" type="text/javascript"></script> <script src="js/jquery.tablesorter.min.js" type="text/javascript"></script> <script type="text/javascript" src="js/jquery.equalHeight.js"></script> <script type="text/javascript"> $(document).ready(function() { $(".tablesorter").tablesorter(); } ); $(document).ready(function() { //When page loads... $(".tab_content").hide(); //Hide all content $("ul.tabs li:first").addClass("active").show(); //Activate first tab $(".tab_content:first").show(); //Show first tab content //On Click Event $("ul.tabs li").click(function() { $("ul.tabs li").removeClass("active"); //Remove any "active" class $(this).addClass("active"); //Add "active" class to selected tab $(".tab_content").hide(); //Hide all tab content var activeTab = $(this).find("a").attr("href"); //Find the href attribute value to identify the active tab + content $(activeTab).fadeIn(); //Fade in the active ID content return false; }); }); </script> <script type="text/javascript"> $(function(){ $('.column').equalHeight(); }); </script> </head> <body> <?php if(session("login") && session("uye_rutbe") == 1){ require_once "inc/default.php"; }else{ } if ($_POST){ $kadi= p("kadi"); $sifre = md5(p("sifre")); if (!$kadi || !$sifre){ echo "kullanıcı adı sifre bos bırakılamaz"; } else{ $row = $connect->query("SELECT * FROM uyeler WHERE uye_kadi = '$kadi' && uye_sifre = '$sifre'"); $row = $connect->fetch(PDO::FETCH_ASSOC); if ( $row["uye_id"]) { $session = array( "giris_yap" => true, "uye_id" => $row["uye_id"], "uye_kadi" => $row["uye_kadi"], "uye_rutbe" => $row["uye_rutbe"] ); session_olustur($session); header("Refresh:0;"); } else { echo "<font color='red'>Böyle Bir Yönetici Yoktur.</font>"; } } } ?> <div id="giris_yap"> <form action="" method="post"> <table cellpadding="0" cellspacing="0"> <tr> <td>Gebruikersnaam:</td> <td><input type="text" name="kadi" /></td> </tr> <tr> <td>Wachtwoord:</td> <td><input type="password" name="sifre" /></td> </tr> <tr> <td></td> <td><button type="submit">Inloggen</button></td> </tr> </table> </form> </div> </body> </html> function.php <?php function p($par, $st =false){ if($st){ return htmlspecialchars(trim($_POST[$par])); }else{ return trim( $_POST[$par]); } } function g($par){ return strip_tag(trim($_GET[$par])); } function kisalt($par,$uzunluk = 50){ if(strlen($par) > $uzunluk){ $par=mb_substr($par,0,$uzunluk,"UTF-8").". ."; } return $par; } function go($par, $time = 0){ if($time == 0){ header("Location: {$par}"); }else{ header("Refresh: {$time}; url={$par}"); } } function session($par){ if ($_SESSION[$par]){ return $_SESSION[$par]; }else{ return false; } } function session_olustur($par){ foreach ($par as $anahtar => $deger){ $_SESSION[$anahtar]=$deger; } } function sef_link($url){ $url = trim($url); $url = strtolower($url); $find = array('<b>', '</b>'); $url = str_replace ($find, '', $url); $url = preg_replace('/<(\/{0,1})img(.*?)(\/{0,1})\>/', 'image', $url); $find = array(' ', '"', '&', '&', '\r\n', '\n', '/', '\\', '+', '<', '>'); $url = str_replace ($find, '-', $url); $find = array('é', 'è', 'ë', 'ê', 'É', 'È', 'Ë', 'Ê'); $url = str_replace ($find, 'e', $url); $find = array('í', 'ì', 'î', 'ï', 'I', 'Ã', 'ÃŒ', 'Ã', 'Ã', 'Ä°', 'ı'); $url = str_replace ($find, 'i', $url); $find = array('ó', 'ö', 'Ö', 'ò', 'ô', 'Ó', 'Ã’', 'Ô'); $url = str_replace ($find, 'o', $url); $find = array('á', 'ä', 'â', 'à ', 'â', 'Ä', 'Â', 'Ã', 'À', 'Â'); $url = str_replace ($find, 'a', $url); $find = array('ú', 'ü', 'Ãœ', 'ù', 'û', 'Ú', 'Ù', 'Û'); $url = str_replace ($find, 'u', $url); $find = array('ç', 'Ç'); $url = str_replace ($find, 'c', $url); $find = array('Å', 'ÅŸ'); $url = str_replace ($find, 's', $url); $find = array('Ä', 'ÄŸ'); $url = str_replace ($find, 'g', $url); $find = array('/[^a-z0-9\-<>]/', '/[\-]+/', '/<[^>]*>/'); $repl = array('', '-', ''); $url = preg_replace ($find, $repl, $url); $url = str_replace ('--', '-', $url); return $url; } function query($query){ return mysql_query($query); } function row($query){ return mysql_fetch_array($query); } function rows($query){ return mysql_num_rows($query); } { } ?> Connect.php <?php session_start(); $host = "localhost"; $database = "blog"; $user = "root"; $password = ""; try { $connect = new PDO("mysql:localhost={$host};dbname={$database}", $user, $password, array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8")); $connect->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING ); } catch (PDOException $e) { return 'Hay Allah!, Connection Error: '. $e->getMessage(); } ?>
  17. yhi

    Help in php

    i want a php scipt to fetch data from columns & display it on a page as table also in <td > i want to add href (reffer a link) the output should be like this <table> <tr><td>ID</td><td>Name</td><td>random</td></tr> <tr><td>1</td><td><a href="profile_link">yhi</a></td><a href'link_2'>some text</td></tr>
  18. Hi everybody! I am building a custom PHP app, and am submitting a form. This form will have between 1 or more textareas, named "textarea1", "textarea2", "textarea200", and so on. I need to read each of these and insert them into a database. How can I script this into the PHP landing page? Is there a way to read all of the values, and names, that are contained in $_POST. Many thanks, Jason
  19. Hello everyone, I have joined this forum just now hoping to find some help for my problem. I have a mysql query in my php file which i output to an array of html divs. The code is as follows: $result = mysql_query("SELECT * FROM numserved WHERE status = 'on'") or die(mysql_error()); while($row = mysql_fetch_array($result)) { ?> <div style="font-size:<?php echo $fontsize; ?>pt;" valign="middle" class="numberz" align="center" > <?php echo $row['number']; ?></div><?php } ?> I wanted to know if anyone could help me write the code to make this query be updated every 3 seconds without reloading the whole page. I know it is done by Ajax and tried to implement the Jquery solution , but I wasnt able to apply it. Anyone would be so kind to tell me the exact code i need and where to place it? Thank you
  20. I am trying to coonect my jquery price slider to my database in order to search for recipes depending on the price. I have written the code below but I am not sure were i am going wrong. Could anyone help? <!--Javascript code for jquery price range slider--> <script type="text/javascript"> $(function() { $( "#slider-range" ).slider({ range: true, min: 0, max: 10, values: [ <?php echo $min?>,<?php echo $max?> ], // This line could be the issue? slide: function( event, ui ) { $( "#amount" ).val( "£" + ui.values[ 0 ] + " - £" + ui.values[ 1 ] ); } }); $( "#amount" ).val( "£" + $( "#slider-range" ).slider( "values", 0 ) + " - £" + $( "#slider-range" ).slider( "values", 1 ) ); }); </script> <!--php code to connect to jquery price slider--> <?php require_once './config.php'; include './header.php'; include('database.php'); if($_POST && isset($_POST['amount'])){ $values = $_POST['amount']; $values = str_replace(array(' ', '£'), '', $_POST['amount']); list($min, $max) = explode('-', $values); $sql = "SELECT `recipe_name`, `recipe_price`, `Image` FROM `recipe` WHERE `recipe_price` BETWEEN :min AND :max"; $stmt = $DB->prepare($sql); $stmt->execute(array(':min' => $min, ':max' => $max)); $rows = $stmt->fetchAll(PDO::FETCH_ASSOC); if (count($rows) > 0) { foreach ($rows as $row) { // do loop stuff } } else { $min = 0; $max = 10; $HTML = ''; } } ?> <!--HTML code for price slider --> <form action="" method="post" id="recipe"> <div style="margin-left:20px"> <label for="amount">Price range:</label> <input type="text" id="amount" name="amount" style="border:0; color:#f6931f; font-weight:bold;" readonly> <br><br> <div id="slider-range" style="width:50%;"></div> <br><br> <input type="submit" value="Find" /> <br><br> <?php echo $HTML?> </div> </form> <!-- connnect to Database - PDO connection--> <?php error_reporting(E_ALL & ~E_DEPRECATED & ~E_NOTICE); ob_start(); define('DB_DRIVER', 'mysql'); define('DB_SERVER', 'localhost'); define('DB_SERVER_USERNAME', 'xxxxx'); define('DB_SERVER_PASSWORD', 'xxxx'); define('DB_DATABASE', 'xxxxx'); define('PROJECT_NAME', 'BudGet Recipes'); $dboptions = array( PDO::ATTR_PERSISTENT => FALSE, PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC, PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8', ); try { $DB = new PDO(DB_DRIVER . ':host=' . DB_SERVER . ';dbname=' . DB_DATABASE, DB_SERVER_USERNAME, DB_SERVER_PASSWORD, $dboptions); } catch (Exception $ex) { echo $ex->getMessage(); die; } ?>
  21. I'm looking to replace a select dropdown with images. My current code for the drop down is <div class="app_services_dropdown_select"> <select name="app_select_services" class="app_select_services"> <option value="1" selected="selected">Class IV MOT (Up to 3,000KG)</option> <option value="2">Class VII MOT (3,000KG - 3,500KG)</option></select> <input type="button" class="app_services_button" value="Show available times"> </div> Which is generated by this code: $s .= '<div class="app_services">'; $s .= '<div class="app_services_dropdown">'; $s .= '<div class="app_services_dropdown_title">'; $s .= $select; $s .= '</div>'; $s .= '<div class="app_services_dropdown_select">'; $s .= '<select name="app_select_services" class="app_select_services">'; if ( $services ) { foreach ( $services as $service ) { $service_description = ''; // Check if this is the first service, so it would be displayed by default if ( $service->ID == $appointments->service ) { $d = ''; $sel = ' selected="selected"'; } else { $d = ' style="display:none"'; $sel = ''; } // Add options $s .= '<option value="'.$service->ID.'"'.$sel.'>'. stripslashes( $service->name ) . '</option>'; } } $s .= '</select>'; $s .= '<input type="button" class="app_services_button" value="'.$show.'">'; $s .= '</div>'; $s .= '</div>'; And I really want an image of a car as value 1 and a van as value 2, plus I really want it to submit on click rather than having the button. Is it possible to replace the dropdown with images instead or would I need to use a radio button, then style it using an image? You can see my current dropdown in use here
  22. I need some help understanding the solution on how to get common values from 3 arrays. Questions on the bits of the code I don't understand is in red. Here is the code and solution: $array1 = [1, 5, 10, 20, 40, 80]; $array2 = [6, 7, 20, 80, 100]; $array3 = [3, 4, 15, 20, 30, 70, 80, 120]; $values = []; foreach ([$array1, $array2, $array3] as $ar) { <-- take the 3 arrays and assign it to $ar - I get this foreach ($ar as $value) { <-- How do you get from 3 arrays in $ar to just the values from the arrays? if (!isset($values[$value])) { <-- If the values array passing in the array values variable $value is not set then it equals 0 / why is this? $values[$value] = 0; } $a = $values[$value]++; <-- Why do you increment this here for what purpose? } } $commonValues = []; foreach ($values as $value => $count) { <-- Can you explain what this foreach is doing? Stepping through it? if ($count > 2) { $commonValues[] = $value; } } print_r($common_values);
  23. Good day everyone, This is my first post here and i am also new to php,so forgive me if my code wrong completely or for any other errors. So i know my code is done is straight php and doesnt really follow the new standard, ill get to that when ive got a good grip on this format.. Im currently design a blog for myself with a back end and all the fun stuff. Ive gotten to the point where everything shows up corrently and its looking great, however I want to show a preview of the article instead of showing the whole article as no one wants to really scroll through huge articles just to get to one that suites them.. So i set up a editor for my content, but for some reason the preview wont load the editor(wysiwyg). could someone assist me and just skim through my code.. Again sorry its in the old format.. <div class="row"> <div class="col-lg-12"> <h1>New post</h1> <?php if(isset($_POST['do_publish'])) { $title = protect($_POST['title']); $content_preview = clean_input($_POST['content_preview']); $content = clean_input($_POST['content']); $tags = protect($_POST['tags']); $category = protect($_POST['category']); $time = time(); if(empty($title) or empty($content) or empty($content_preview) or empty($tags) or empty($category)) { echo error("All fields are required."); } elseif(strlen($title)>60) { echo error("Post title must be less than 60 characters."); } else { $insert = mysql_query("INSERT blogger_posts (title,content,content_preview,author,category,time,tags) VALUES ('$title','$content_preview','$content','$_SESSION[user_id]','$category','$time','$tags')"); $row = mysql_fetch_array(mysql_query("SELECT * FROM blogger_posts WHERE author='$_SESSION[user_id]' ORDER BY id DESC LIMIT 1")); $link = $url.'post/'.make_post_link($row[id]).'-'.$row[id]; $link = '<a href="'.$link.'" target="_blank">'.$link.'</a>'; $month = date("m"); $year = date("Y"); $check_archive = mysql_query("SELECT * FROM blogger_archives WHERE month='$month' and year='$year'"); if(mysql_num_rows($check_archive)>0) { $archive = mysql_fetch_array($check_archive); $insert_archive_post = mysql_query("INSERT blogger_archives_posts (post_id,archive_id) VALUES ('$row[id]','$archive[id]')"); } else { $create_archive = mysql_query("INSERT blogger_archives (month,year) VALUES ('$month','$year')"); $archive = mysql_fetch_array(mysql_query("SELECT * FROM blogger_archives WHERE month='$month' and year='$year'")); $insert_archive_post = mysql_query("INSERT blogger_archives_posts (post_id,archive_id) VALUES ('$row[id]','$archive[id]')"); } $tags = explode(",",$tags); foreach ($tags as $tag) { $tag = str_replace(' ','',$tag); $check_tag = mysql_query("SELECT * FROM blogger_popular_tags WHERE tag='$tag'"); if(mysql_num_rows($check_tag)>0) { $update_tag = mysql_query("UPDATE blogger_popular_tags SET used=used+1 WHERE tag='$tag'"); } else { $insert_tag = mysql_query("INSERT blogger_popular_tags (tag,used) VALUES ('$tag','1')"); } } $get_subscribers = mysql_query("SELECT * FROM blogger_subscribers ORDER BY id"); if(mysql_num_rows($get_subscribers)>0) { while($subscriber = mysql_fetch_array($get_subscribers)) { $to = $subscriber['email']; $subject = $web['web_name']." publish new post"; $message = 'Hi '.$subscriber[email].' We publish a new post in our blog you can preview it here: '.$url.'post/'.make_post_link($row[id]).'-'.$row[id].' If you do not wish to receive such messages more can unsubscribe here: '.$url.'unsubscribe/'.$subscriber[hash].' Do not reply on this message.'; $headers = 'From: '.$web[web_email].'' . "\r\n" . 'Reply-To: '.$web[web_email].'' . "\r\n" . 'X-Mailer: PHP/' . phpversion(); mail($to, $subject, $message, $headers); } } echo success("Your new post was published successfully.<br/>Click on link to preview post: $link"); } } ?> <form role="form" action="" method="POST"> <div class="form-group"> <label>Post title</label> <input type="text" class="form-control" name="title" placeholder="Post title *"> </div> <div class="form-group"> <label>Content_preview</label> <textarea id="editor" class="textarea" name="content_preview"></textarea> </div> <div class="form-group"> <label>Content</label> <textarea id="editor" class="textarea" name="content"></textarea> </div> <div class="form-group"> <label>Tags</label> <input type="text" class="form-control" name="tags" placeholder="Example: post, tag1, title, tag2, bla, bla"> </div> <div class="form-group"> <label>Category</label> <select name="category" class="form-control"> <?php $get_cats = mysql_query("SELECT * FROM blogger_categories ORDER BY id"); if(mysql_num_rows($get_cats)>0) { while($cat = mysql_fetch_array($get_cats)) { echo '<option value="'.$cat[id].'">'.$cat[value].'</option>'; } } else { echo '<option>No have categories.</option>'; } ?> </select> </div> <button type="submit" class="btn btn-default" name="do_publish">Publish</button> </form> </div> </div> obviously this is for the back end.. Im sure i can transfer the solution to the other pages. let me know if you need more code.. thank you so much in advance..
  24. I cannot view data based upon my "wid" in the following code. Basically I have a page that you click on a link, and it passes a number to the "wid" as an integer. I want to call on that corresponding table that has a "like" wid. Here is what I have so far... <?php require 'database.php'; if(!empty($_GET['wid'])) { $wid = $_GET['wid']; } else { $wid = null; } if ( null==$wid ) { header("Location: workorders.php"); } else { $pdo = Database::connect(); $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $sql = 'SELECT * FROM items where wid = ?'; $rows = $pdo->query($sql); foreach ($pdo->query($sql) as $row) { echo '<tr>'; echo '<td>'. $row['id'] . '</td>'; echo '<td>'. $row['wid'] . '</td>'; echo '<td>'. $row['model'] . '</td>'; echo '<td>'. $row['description'] . '</td>'; echo '<td>'. $row['cost'] . '</td>'; echo '<td>'. $row['retail'] . '</td>'; echo '<td>'. $row['tax'] . '</td>'; echo '<td width=250>'; } Database::disconnect(); } ?>
  25. i just downloaded this software interspire email marketer to send email campaigns but in the process of sending out email i get to a page where i select the email list i want the email campaign to go to out to. but after i make this selection and click the "Next"button nothig happens. i just click on the button but it doesnt lead to the next page at all. it just remains in the same page. this is very frustrating so i did some research and did a "View Page Source"on mozilla and i found this in the code for that button: <input class="FormButton SubmitButton" type="button" value="Next >>" /> <input class="FormButton CancelButton" type="button" value="Cancel" /> i'm a noob so i looked up the internet and saw that the code here should look more like this below for the button to function like it should: <input class="FormButton SubmitButton" type="submit" value="Next >>" /> <input class="FormButton CancelButton" type="button" value="Cancel" /> my issue however came when i tried to correct this on the webpage code. i downloaded a php editor but it could not locate the page for editing....the page is: http://naudeyfire.atwebpages.com/marketing/admin/index.php?Page=Send but the phpeditor does not locate this page...i do not see it when using ftp ...i only see http://naudeyfire.atwebpages.com/marketing/admin/index.php so my question is two-fold: 1) is it true that changing that code from "button"to "submit" will enable me to proceed to the next page that the button is supposed to link to? 2) how do i find this exact page in order to correct and update it on the server? thank you very much ...
×
×
  • 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.