Jump to content

HDFilmMaker2112

Members
  • Posts

    547
  • Joined

  • Last visited

    Never

Everything posted by HDFilmMaker2112

  1. This doesn't work when you want to format data entered in different formats. It won't accept a number with the comma as a decimal separator. I need to be able to accept various inputs: 1234.56 1234 1,234.56 1,234 1.234,56 1.234 and have them all enter into the database as 1234.56
  2. I came up with this, based on something I copied from php.net. The only issue I have is when I enter a value of 1,234,567 it prints out twice. Like this: 12345671234567 <?php $convertnum="1,123,234.86"; $bits = explode(",",$convertnum); // split input value up to allow checking $first = strlen($bits[0]); // gets part before first comma (thousands/millions) $last = strlen($bits[1]); // gets part after first comma (thousands (or decimals if incorrectly used by user) if ($last <3){ // checks for comma being used as decimal place $convertnum = str_replace(",",".",$convertnum); } else{ // assume comma is a thousands seperator, so remove it $convertnum = str_replace(",","",$convertnum); } $thousands = explode(".",$convertnum); $period_count = count($thousands); if($period_count > 1){ $convertnum=str_replace(".",",",$thousands[0]); } for($i=1; $i < $period_count-1; $i++){ $convertnum.="".$thousands[$i]; } $cent_count=strlen($thousands[$period_count-1]); if($cent_count < 3 && $period_count==$period_count){ $convertnum.=".".$thousands[$period_count-1]; } else{ $convertnum.=$thousands[$period_count-1]; } echo $convertnum; // redefine the value of the variable, to be the new corrected one ?>
  3. I'm looking to know if preg_replace would be the best option to format a users input of a money amount? With multiple different types of entries, it seems it may not work. IE: The four currency formats I know of: 1,200.94 1,200 1.200,94 1.200 How would I be able to replace the decimals and commas, without messing up their positioning? I want to end up with a number formatted in the 1,200.94 format.
  4. Alright, now it works briefly. I can log-in, click a few links come back, and it's fine. Click a few more and come back, and it's now the log-in form again. It's like the session last for about 15 seconds. EDIT: Got it. Thanks for the help. <?php require_once 'func.php'; session_start(); print_r($_SESSION); if(isset($_SESSION['myusername2']) && kam3($_POST['password'])==$_SESSION['mypassword2'] || isset($_SESSION['myusername2']) && $_SESSION['mypassword3']==$_SESSION['mypassword2']){ if(!empty($_POST['password'])){ $_SESSION['mypassword3']=kam3($_POST['password']); } $content.=' <div class="main"> <div class="main_header">Admin CP</div> </div> '; } else{ $content=' <table class="actors_table"> <tr> <td align="center">'; if(isset($_GET['e']) && $_GET['e']=="0") { $content .= '<span style="color: #FF0000; font-weight: bold;">Incorrect Username or Password</span><br/><br/>'; } else{ $content .=""; } $content .='Re-Type your password to view this information: <form action="" method="post"> <p>Username: <input type="text" name="username" value="'.$_SESSION['myusername2'].'" disabled="disabled" /></p> <p>Password: <input type="password" name="password" /></p> <p><input type="submit" value="Submit" name="Submit" /></p> </form> </td> </tr> </table> '; } ?>
  5. The hashed passwords mypassword2 and mypassword3 have different values. Once I log-in each time they're identical, click to another page, and come back to the form, they're different again. I think it's because the POST is assigning to the mypassword3 session outside the if statement, so therefore when come back to the page after clicking away, it's a hashing a blank entry thus giving a different hashed value.
  6. Looks like: echo $details_result; = a resource id echo $count_details; = 0
  7. I cut it down to this, and it logs in once, but if you click away from the page and come back, the form comes up again, as if the session was never set. <?php require_once 'func.php'; session_start(); $_SESSION['mypassword3']=kam3($_POST['password']); if(isset($_SESSION['myusername2']) && $_SESSION['mypassword3']==$_SESSION['mypassword2']){ $content.=' <div class="main"> <div class="main_header">Admin CP</div> </div> '; } else{ $content=' <table class="actors_table"> <tr> <td align="center">'; if(isset($_GET['e']) && $_GET['e']=="0") { $content .= '<span style="color: #FF0000; font-weight: bold;">Incorrect Username or Password</span><br/><br/>'; } else{ $content .=""; } $content .='Re-Type your password to view this information: <form action="" method="post"> <p>Username: <input type="text" name="username" value="'.$_SESSION['myusername2'].'" disabled="disabled" /></p> <p>Password: <input type="password" name="password" /></p> <p><input type="submit" value="Submit" name="Submit" /></p> </form> </td> </tr> </table> '; } ?>
  8. No they are hashed I just removed it from what I posted here.
  9. The below is giving an error, saying that the password is incorrect. I know for a fact it's correct. <?php if(isset($_SESSION['myusername2']) && isset($_SESSION['mypassword3'])){ $content.=' <div class="main"> <div class="main_header">Admin CP</div> </div> '; } else{ $content=' <table class="actors_table"> <tr> <td align="center">'; if(isset($_GET['e']) && $_GET['e']=="0") { $content .= '<span style="color: #FF0000; font-weight: bold;">Incorrect Username or Password</span><br/><br/>'; } else{ $content .=""; } $content .='Re-Type your password to view this information: <form action="./adminlogin.php" method="post"> <p>Username: <input type="text" name="username" value="'.$_SESSION['myusername2'].'" disabled="disabled" /></p> <p>Password: <input type="password" name="password" /></p> <p><input type="submit" value="Submit" name="Submit" /></p> </form> </td> </tr> </table> '; } ?> <?php require_once 'db_select.php'; require_once 'func.php'; session_start(); // username and password sent from form $myusername=sanitize($_POST['username']); $mypassword=sanitize($_POST['password']); $check_details="SELECT * FROM $tbl_name WHERE username='$myusername' AND password='$mypassword'"; $details_result=mysql_query($check_details); // Mysql_num_row is counting table row $count_details=mysql_num_rows($details_result); // If result matched $myusername and $mypassword, table row must be 1 row if($count_details==1){ $_SESSION['mypassword3']=$mypassword; header("location:index.php?usercp"); } else{ header('Location:./index.php?admincp&e=0'); } ?>
  10. I think the issue is because it's a scroll table. Some of the left side of the table protrudes out further than other parts. Each row seems to have a slightly different width, when they're all set from the same CSS. It's not an issue at in IE. The above is just what I could get right now... occassionally it's much worse. It varies based on scrolling the table or scrolling the page.
  11. Actually there is, I forgot to mention the page funnels into a Non-disclosure agreement (gateway page), click through it and you'll see the tables.
  12. On the following site: http://makethemoviehappen.com/index.php Do the tables look lumpy when you scroll through the Credits tables? On my computer the tables rows vary in width a few pixels giving a bumpy look to the tables. I don't see this on IE8. Is this only my comp. or a firefox bug?
  13. Put an id tag for each comment, and get the id of the last added comment and append that to the URL with #. Don't use <a name> it's deprecated.
  14. <?php // define menus $menu = array(); $menu['user_investor'] = array("Films" => "$page.php?films","Webseries" => "$page.php?webseries","Company" =>"$page.php?company"); $menu['user_donor'] = array("<a href='$page.php?contact'>Contact</a>","<a href='index.php?faq'>FAQ</a>","<a href='http://store.makethemoviehappen.com'>Store</a>"); $menu['user_other'] = array("<a href='$page.php?donate'>Donate</a>","<a href='$page.php?contact'>Contact</a>","<a href='$page.php?faq'>FAQ</a>"); // logic to determine which menu to use if(isset($_GET['test'])){ $type = 'user_investor'; } elseif(isset($_SESSION['myusername2'])){ $type = 'user_donor'; } else { $type = 'user_other'; } $menu_text = array_keys($menu[$type]); // produce and output the correct menu $i=0; foreach(array_values($menu[$type]) as $link){ echo '<div class="tab">'; echo '<a href="'.$link.'">'; echo $menu_text[$i]; echo '</a>'; echo "</div>"; $i++; } ?>
  15. The below is out putting: FilmsWebseriesCompany - >?films FilmsWebseriesCompany - >?webseries FilmsWebseriesCompany - >?company I need it to iterate through each link name once. <?php // define menus $menu = array(); $menu['user_investor'] = array("Films" => "$page.php?films","Webseries" => "$page.php?webseries","Company" =>"$page.php?company"); $menu['user_donor'] = array("<a href='$page.php?contact'>Contact</a>","<a href='index.php?faq'>FAQ</a>","<a href='http://store.makethemoviehappen.com'>Store</a>"); $menu['user_other'] = array("<a href='$page.php?donate'>Donate</a>","<a href='$page.php?contact'>Contact</a>","<a href='$page.php?faq'>FAQ</a>"); // logic to determine which menu to use if(isset($_GET['test'])){ $type = 'user_investor'; $menu_text = array_keys($menu['user_investor']); } elseif(isset($_SESSION['myusername2'])){ $type = 'user_donor'; $menu_text = array_keys($menu['user_donor']); } else { $type = 'user_other'; $menu_text = array_keys($menu['user_other']); } // produce and output the correct menu foreach($menu[$type] as $link){ echo "<div class='tab'>"; echo '<a href="'.$link.'">'; for($i=0; $i <= count($menu_text); $i++){ echo $menu_text[$i]; } echo '</a>'; echo "</div>"; } ?> \
  16. Here's what I ended up with... cut down on the redundant text as much as possible. <div class="tab"> <a href="<?php echo $page; if(isset($_SESSION['myusername'])){ '.php?films">Films';} elseif(isset($_SESSION['myusername2'])){ echo '.php?contact">Contact';} else { echo '.php?donate">Donate';} ?> </a> </div>
  17. Finally find the link to that page: http://us3.php.net/manual/en/language.basic-syntax.phpmode.php
  18. It says right on php.net it's always better to break out of php to display HTML code. I always thought breaking in and out like that would slow things down but apparently it's what you should be doing.
  19. Looking to know if I should convert the below to a switch statements for efficiency? All the opening and closing php tags is getting to me. <div class="tab"> <? if(isset($_SESSION['myusername'])){?> <a href="<? echo $page; ?>.php?films">Films</a><? } elseif(isset($_SESSION['myusername2'])){?> <a href="<? echo $page; ?>.php?contact">Contact</a><? } else { ?> <a href="<? echo $page; ?>.php?donate">Donate</a> <? } ?> </div> <div class="tab"> <? if(isset($_SESSION['myusername'])){?> <a href="index.php?webseries">Webseries</a><? } elseif(isset($_SESSION['myusername2'])){?> <a href="index.php?faq">FAQ</a><? } else { ?> <a href="<? echo $page; ?>.php?contact">Contact</a> <? } ?> </div> <div class="tab"> <? if(isset($_SESSION['myusername'])){?> <a href="index.php?company">Company</a><? } elseif(isset($_SESSION['myusername2'])){?> <a href="http://store.makethemoviehappen.com">Store</a><? } else { ?> <a href="<? echo $page; ?>.php?faq">FAQ</a> <? } ?> </div> <div class="tab"> <? if(isset($_SESSION['myusername'])){?> <a href="index.php?contact">Contact</a><? } elseif(isset($_SESSION['myusername2'])){?> <a href="index.php?usercp">User CP</a><? } else { ?> <a href="<? echo $page; ?>.php?investors">Investors</a> <? } ?> </div>
  20. Does the php have line breaks in it? http://www.the-art-of-web.com/php/javascript-escape/
  21. I'm trying to set-up a function for me to choose which database to use, by place a call to the function with either number 1 or 2. $db_name="zyquo_donors"; // Database name $db_name2="zyquo_investors"; $tbl_name="donors"; // Table name $tbl_name2="donors_credits"; $tbl_name3="members"; mysql_connect("$host", "$username", "$password")or die("cannot connect"); function db_select($db="1"){ if($db=="1"){ mysql_select_db("$db_name")or die("cannot select DB"); } elseif($db=="2"){ mysql_select_db("$db_name2")or die("cannot select DB"); } } and on the page I have: db_select("2"); The result is: cannot select DB
  22. For some reason the first ternary operator is evaluating to false and running true for the second one, when $_SESSION['myusername']is set. Anybody see anything in the code below or is this an issue with the sessions being set. <? echo (isset($_SESSION['myusername'])) ? '<a href="'.$page.'.php?films">Films' : (isset($_SESSION['myusername2'])) ? '<a href="'.$page.'.php?contact">Contact' : '<a href="'.$page.'.php?donate">Donate'; ?></a>
  23. <a href="<?php echo (isset($_SESSION['myusername'])) ? $page."php?investors=home" : $page.".php"; ?>">Home</a>
  24. The below is placing nothing inside the href="" area when viewed. <a href="<?php (isset($_SESSION['myusername'])) ? $page."php?investors=home" : $page.".php"; ?>">Home</a>
  25. Are you calling the class before the function? I'm not great at OO programming but, I believe that's what you need to do: http://www.killerphp.com/tutorials/object-oriented-php/php-objects-page-2.php Step 10.
×
×
  • 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.