Jump to content

Search the Community

Showing results for tags 'recoding'.

  • 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

Found 1 result

  1. Hi, freaks! I have a problem that I thought is very small, but unfortunately when I started to edit the index.php all the content crashed. I have to edit a game website in PHP. The game is sitiated on the page "Play". It contains 4 questions and when they are answered right, it redirects to a registration form where everyone can fill his data. The problem is that now I don't want these questions and and what I want is when someone open page Play only the registration form to be loaded. The filled data is sent to a database. When I remove some of the steps, the website brokes. When I remove one of the functions which check if the questions are answered, the button Send doesn't work, so now after 3 days work I'm really stuck. I'm beginner in PHP coding and I will be very thankful if you can help me. Here is the idex.php code: <? require_once('config.php'); $names=''; $first=''; $last=''; $dob=''; $email=''; $phone=''; $error=0; $message=''; $subject=''; $content=''; if(!empty($_POST['contact']) && (int)$_POST['contact']==1){ $names=trim(strip_tags($_POST['names'])); $email=trim(strip_tags($_POST['email'])); $phone=trim(strip_tags($_POST['phone'])); $subject=trim(strip_tags($_POST['subject'])); $content=trim(strip_tags($_POST['content'])); if(empty($names) || empty($email) || empty($content)){ $error=1; $message.='Please, fill all the fields marked with *<br>'; } elseif(!filter_var($email,FILTER_VALIDATE_EMAIL)){ $error=1; $message.='The email is wrong.<br>'; } if(!$error){ $headers="From:".$email_from."\r\n"; $body = 'Name: '.$names."\n"; $body .= 'email: '.$email."\n"; $body .= 'Telephone: '.$phone."\n"; $body .= 'IP address: '.$_SERVER['REMOTE_ADDR']."\n\n"; $body .= 'Sent date: '.date('r')."\n\n"; $body .= 'about:\n'.$subject."\n\n"; $body .= 'message:\n'.$content."\n\n"; $sent=mail($email_to,($subject?$subject:'subject not entered'), $body, $headers); if($sent){ header('Location: ?p=contacts&ok=1'); exit; } else { $error=1; $message.='An error has ocurred. Please, try again later.<br>'; } } } if(!empty($_POST['register']) && (int)$_POST['register']==1){ $first=trim(strip_tags($_POST['first'])); $last=trim(strip_tags($_POST['last'])); $dob=trim(strip_tags($_POST['dob'])); $email=trim(strip_tags($_POST['email'])); $phone=trim(strip_tags($_POST['phone'])); $subscribe=intval($_POST['subscribe']); if(empty($first) || empty($last) || empty($dob) || empty($email) || empty($phone)){ $error=1; $message.='Please fill all the fields.<br>'; } elseif(!filter_var($email,FILTER_VALIDATE_EMAIL)){ $error=1; $message.='The email is wrong.<br>'; } elseif(mysql_result(mysql_query('select count(*) from _participants where email ="'.mysql_real_escape_string($email).'"'),0,0)){ $error=1; $message.='The email is already used.<br>'; } if(!$error){ $sql='insert into _participants (created, first, last, bdate, email, phone, subscribe, ip) values ( NOW(), "'.mysql_real_escape_string($first).'", "'.mysql_real_escape_string($last).'", "'.mysql_real_escape_string($dob).'", "'.mysql_real_escape_string($email).'", "'.mysql_real_escape_string($phone).'", '.$subscribe.', INET_ATON("'.$_SERVER['REMOTE_ADDR'].'") )'; $q=mysql_query($sql); if($q){ $_SESSION['step']=6; header('Location: ?p=play&s='.rand()); exit; } } } $pages=array(); $pages['index']='Home'; $pages['terms']='Rules'; $pages['play']='Play'; $pages['awards']='Awards'; $pages['contacts']='Contacts'; // where are we $page='index'; if(!empty($_GET['p']) && isset($pages[$_GET['p']])){ $page=$_GET['p']; } ?><!doctype html> <html> <head> <meta charset="UTF-8" /> <meta name="viewport" content="width=device-width" /> <title>Website Name</title> <link rel="stylesheet" type="text/css" media="all" href="style.css" /> <script type='text/javascript' src='js/jquery.min.js'></script> <script type='text/javascript' src='js/site.js'></script> </head> <body class=<?=$page?>> <div id=wrap> <div id=header> <div id=web_head> <div id=web_logo> Web </div> <div id=web_slogan> Company Name </div> </div> <div id=nav> <? foreach($pages as $p=>$title){ ?> <a href="<?=($p=='index'?'index.php':'?p='.$p)?>" <?=($p=='index'?'class="first'.($p==$page?' active':'').'"' $p==$page?'class=active':''))?>><?=$title?></a> <? } ?> </div> </div> <div id=main> <? switch($page){ case 'play': echo page_play(); break; case 'terms': echo page_terms(); break; case 'awards': echo page_awards(); break; case 'contacts': echo page_contacts(); break; case 'index': default: echo page_index(); break; } ?> </div> <div id=footer></div> </div> </body> </html> <? function check_step() { $step=(int)$_SESSION['step']; switch($step){ case 1: if(!empty($_POST['q1']) && intval($_POST['q1'])==2){ $_SESSION['step']=2; } break; case 2: if(!empty($_POST['q2']) && intval($_POST['q2'])>0 && intval($_POST['q2'])<4){ $_SESSION['step']=3; } break; case 3: if(!empty($_POST['q3']) && intval($_POST['q3'])==3){ $_SESSION['step']=4; } break; case 4: if(!empty($_POST['q4']) && intval($_POST['q4'])==3){ $_SESSION['step']=5; } break; } } function play_step() { global $message, $first, $last, $dob, $email, $phone, $error; if(empty($_SESSION['step'])){ $_SESSION['step']=1; } if(!empty($_POST)){ check_step(); } $step=(int)$_SESSION['step']; $r=''; switch($step){ case 5: $r.=' <div class=q id=success> <h1>Congratulation!</h1> <h2>You've answered all the questions. Fill the registration form to participate in the game.</h2> '.(!empty($message)?'<div class=message>'.$message.'</div>':'').' <div class=fields> <label for=first>Name: *</label><input type=text name=first value="'.str_replace('"','"',$first).'"><br> <label for=last>Family name: *</label><input type=text name=last value="'.str_replace('"','"',$last).'"><br> <label for=dob>Date of birth: *</label><input type=text name=dob value="'.str_replace('"','"',$dob).'" placeholder="дд.мм.гггг"><br> <label for=email>Email: *</label><input type=text name=email value="'.str_replace('"','"',$email).'"><br> <label for=phone>Telephone: *</label><input type=text name=phone value="'.str_replace('"','"',$phone).'"><br> <label class=long for=subscribe>I want to have news from you</label> <span class=radio_block><input type=radio value=0 name=subscribe '.( (isset($_POST['subscribe']) && (int)$_POST['subscribe']==0) || !isset($_POST['subscribe'])?' checked':'').'> No <input type=radio value=1 name=subscribe '.(isset($_POST['subscribe']) && (int)$_POST['subscribe']==1?' checked':'').'> Yes</span><br><br> <label class=long>I agree with the Terms <a href="?p=terms" target="_blank">Terms</a></label><br><br><br> <input type=hidden value=1 name=register> <button>Send</button> </div> </div> '; break; case 4: $r.=' <div class=q id=q_4> <h1>4. Question 4?</h1> <label class="label_radio" for="q4"><input type=radio name=q4 value=1 data-check=3> A. Answer 1</label> <label class="label_radio" for="q4"><input type=radio name=q4 value=2 data-check=3> B. Answer 2</label> <label class="label_radio" for="q4"><input type=radio name=q4 value=3 data-check=3> C. Answer 3</label> <div class=products></div> <div class=comment id=q4_1 style="display:none">Your answer is wrong! </div> <div class=comment id=q4_2 style="display:none">Your answer is wrong!</div> <div class=comment id=q4_3 style="display:none">Correct answer!</div> </div> '; break; case 3: $r.=' <div class=q id=q_3> <h1>3. Question 3?</h1> <label class="label_radio" for="q3"><input type=radio name=q3 value=1 data-check=3> A. Answer 1</label> <label class="label_radio" for="q3"><input type=radio name=q3 value=2 data-check=3> B. Answer 2</label> <label class="label_radio" for="q3"><input type=radio name=q3 value=3 data-check=3> C. Answer 3</label> <div class=products></div> <div class=comment id=q3_1 style="display:none">Your answer is wrong!</div> <div class=comment id=q3_2 style="display:none">Your answer is wrong!</div> <div class=comment id=q3_3 style="display:none">Correct answer!</div> </div> '; break; case 2: $r.=' <div class=q id=q_2> <h1>2. Question 2?</h1> <label class="label_radio" for="q2"><input type=radio name=q2 value=1 data-check=1> A. Answer 1</label> <label class="label_radio" for="q2"><input type=radio name=q2 value=2 data-check=2> B. Answer 2</label> <label class="label_radio" for="q2"><input type=radio name=q2 value=3 data-check=3> C. Answer 3</label> <div class=products></div> <div class=comment id=q2_1 style="display:none">Your answer is wrong! </div> <div class=comment id=q2_2 style="display:none">Your answer is wrong! </div> <div class=comment id=q2_3 style="display:none">Correct answer!</div> </div> '; break; case 1: default: $r.=' <div class=q id=q_1> <h1>1. Question 1?</h1> <table> <tr> <td> <h2>A. Answer 1<br><br></h2> <label class="label_radio" for="q1"><input type=radio name=q1 value=1 data-check=2> </label> </td> <td> <h2>B. Answer 2</h2> <label class="label_radio" for="q2"><input type=radio name=q1 value=2 data-check=2> </label> </td> </tr> </table> <div class=products></div> <div class=comment id=q1_1 style="display:none">Your answer is wrong!</div> <div class=comment id=q1_2 style="display:none">Correct answer!</div> </div> '; break; } return $r; } function page_play() { global $message, $first, $last, $dob, $email, $phone, $error; if(isset($_SESSION['step']) && $_SESSION['step']==6){ unset($_SESSION['step']); $r=' <div class=q id=success> <h1>Thanks for your participation</h1> <h2>Wait for the winners next week</h2> '; } else { $r='<form id=player action="" method=post>'; $r.=play_step(); $r.='<div id=continue style="display:none"></div>'; $r.='<div id=try_again class=play_btn style="display:none">Try again</div>'; $r.='</form>'; } return $r; } function page_contacts() { global $message, $names, $phone, $email, $subject, $content; if(!empty($_GET['ok'])){ $r='<div><h1>Your message was successfully sent.</h1></div>'; return $r; } $r=''; $r.='<div><h1>Contact form:</h1> '.(!empty($message)?'<div class=message>'.$message.'</div>':'').' <form id=contact_form method=post> <div class=long> <label for="names">Name: *</label> <input type=text name=names value="'.str_replace('"','"', $names).'"> </div> <div class=short> <label for="phone">Telephone: </label> <input type=text name=phone value="'.str_replace('"','"', $phone).'"> </div> <div class="short last"> <label for="email">E-mail: *</label> <input type=text name=email value="'.str_replace('"','"', $email).'"> </div> <div class=long> <label for="subject">about: </label> <input type=text name=subject value="'.str_replace('"','"', $subject).'"> </div> <div class=long> <label for="message">Free text: *</label> <textarea name=content>'.str_replace('"','"', $content).'</textarea> </div> <input type=hidden value=1 name=contact> <button class=play_btn>Send</button> </form> </div> '; return $r; } function page_awards() { $r=''; $r.='<div><h1>Awards</h1> <a href="?p=play" class=play_btn>play now</a> </div>'; return $r; } function page_terms() { $r=''; $r.='<div><h1>Rules</h1> Some rules return nl2br($r); } function page_index() { /* $r=''; $r.='<h1>Play and win</h1>'; $r.=''; $r.='<a href="?p=play" class=play_btn>play now</a>'; */ $r=' <div style="font-size:14px;text-align:left;padding:10px"><h1 style="font-size:18px;padding:25px 0">Winners in the game </div> '; return $r; } ?> index.php
×
×
  • 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.