Jump to content

HDFilmMaker2112

Members
  • Posts

    547
  • Joined

  • Last visited

    Never

Posts posted by HDFilmMaker2112

  1. Alright... I converted it to date column in my table... Now I have a rma_date_issued column... Really have no idea where to go from here.

     

     

    I have this right now:

    elseif($_GET['rma']=="calander"){
    $sql101010="SELECT DISTINCT rma_date_issued FROM $tbl_name4 ORDER BY rma_date_issued";
    $result101010=mysql_query($sql101010);
    while($row101010=mysql_fetch_array($result101010)){
    extract($row101010);
    $date_issued=date_create($rma_date_issued);
    $rma_year_issued=date_format($date_issued, 'Y');
    $content.='<a href="./acp_admincp.php?rma=calander&year='.$rma_year_issued.'">'.$rma_year_issued.'</a>
    <br />';
    }
    if(isset($_GET['year'])){
    $logout.=' | <a href="./acp_admincp.php?rma=calander">Back to RMA Calander</a>';
    $rma_year_issued=$_GET['year'];
    $content="";
    $content.=$rma_year_issued;
    }
    }
    

     

    What should I do to create the page that lists the months?

  2. Trying to get the below to generate the month in word form from a numeric entry in a database.

    elseif($_GET['rma']=="calander"){
    $sql101010="SELECT DISTINCT rma_year_issued FROM $tbl_name4 ORDER BY rma_year_issued";
    $result101010=mysql_query($sql101010);
    while($row101010=mysql_fetch_array($result101010)){
    extract($row101010);
    $content.='<a href="./acp_admincp.php?rma=calander&year='.$rma_year_issued.'">'.$rma_year_issued.'</a>
    <br />';
    }
    
    if(isset($_GET['year'])){
    $logout.=' | <a href="./acp_admincp.php?rma=calander">Back to RMA Calander</a>';
    $rma_year_issued=$_GET['year'];
    $sql111010="SELECT DISTINCT rma_month_issued FROM $tbl_name4 WHERE rma_year_issued='$rma_year_issued' ORDER BY rma_month_issued";
    $result111010=mysql_query($sql111010);
    while($row111010=mysql_fetch_array($result111010)){
    extract($row111010);
    $months = array('Janurary', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December');
    for($i=0; $i <=11; $i++){
    if($rma_month_issued=$i){
    $rma_month_issued2=$months[$i];
    }
    }
    $content="";
    $content.='<a href="./acp_admincp.php?rma=calander&year='.$rma_year_issued.'&month='.$rma_month_issued.'">'.$rma_month_issued2.'</a>
    <br />';
    
    }
    }
    }
    

     

    Basically in the data base I may have 2,5,7 under the year 2011.

     

    I want to get the numeric months into words for use in the text of the link.

     

    The above is returning December even though the entry in the database is 5.

  3. Just went with this instead.

     

    if($rma_issued=="y"){
    $length = 2;
    $characters = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
    $string= microtime(true);
    for ($p = 0; $p < $length; $p++) {
    $string .= $characters[mt_rand(0, strlen($characters))];
    }
    for ($p = 0; $p < $length; $p++) {
    $string2 .= $characters[mt_rand(0, strlen($characters))];
    }
    $string="".$string2."".$string;
    $string=explode(".",$string);
    $string=$string[0].$string[1];
    $rma_number=$string;
    $sql2000000="UPDATE $tbl_name4 SET rma_number='$rma_number', rma_issued='$rma_issued' WHERE rma_id = $rma_id";
    mysql_query($sql2000000);
    header("Location: ./acp_admincp.php?rma=issued");
    }
    

  4. edit:

     

    hmm...well, I guess I didn't fully look at your code.  Seems like you start out by prefixing with microtime, but then do stuff after that that takes the main use for it out of the picture.  Is there a reason you can't make this "random string" keep the full microtime prefix?

     

     

    I'm taking off the first 4 digits of microtime, which are pretty much always the same. And appending the randomly generated letters and numbers to the front and back. The first 4 digital of microtime should be 1306 for the foreseeable future. I could keep the full microtime + generate letters and numbers for the beginning and end, I was just trying to keep it under 12 characters. But that's really not all the necessary, I guess.

  5. Going back to my original code... I need it to generate a random number/key, search the Database, if there's already an entry with the same key, rerun the key generation. If there are no duplicate entries insert the key generated.

     

    So I'm thinking do{} while($num_rows!=1); should work. It should, if there's no duplicates, insert the key, loop back around and redo the do statement, and catch that there's now an entry and stop executing... correct?

     

    So:

     

    do{
    $length = 2;
    $characters = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
    $string ="";
    $string.= microtime(true);
    for ($p = 0; $p < $length; $p++) {
    $string .= $characters[mt_rand(0, strlen($characters))];
    }
    $string= substr_replace($string, '', 0, 4);
    for ($p = 0; $p < $length; $p++) {
    $string2 .= $characters[mt_rand(0, strlen($characters))];
    }
    $string="".$string2."".$string;
    $string=explode(".",$string);
    $string=$string[0].$string[1];
    $rma_number=$string;
    
    $sql12345="SELECT * FROM $tbl_name4 WHERE rma_number=$rma_number";
    $result12345=mysql_query($sql12345);
    $num_rows12345=mysql_num_rows($result12345);
    }
    while($num_rows12345 != 1);
    
    if($num_rows12345==0){
    $sql2000000="UPDATE $tbl_name4 SET rma_number='$rma_number', rma_name='$rma_name' WHERE rma_id = $rma_id";
    mysql_query($sql2000000);
    }
    

  6. Alright I'm going crazy trying to figure out if this would work or not. I found a do-while script on the net and altered it slightly:

     

    <?
    $cookies = 0;
    do{
    echo "Mmmmm...I love cookies! *munch munch munch*";
    $cookies++;
    } 
    while ($cookies != 1);
    
    if($cookies==1){
    echo "test test";
    }
    ?>
    

     

    The above executes once when $cookies=0, and goes crazy and fills the page (continues executing) when equal to or above 1. Is this what I'm looking for?

  7. Is there any way to invert a Do-While loop so it continues to loop through the Do statement if the While statement is FALSE. And then end execution once the While statement is true. I guess I would basically need something like a Do-Until statement...

    do{
    $length = 2;
    $characters = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
    $string ="";
    $string.= microtime(true);
    for ($p = 0; $p < $length; $p++) {
    $string .= $characters[mt_rand(0, strlen($characters))];
    }
    $string= substr_replace($string, '', 0, 4);
    for ($p = 0; $p < $length; $p++) {
    $string2 .= $characters[mt_rand(0, strlen($characters))];
    }
    $string="".$string2."".$string;
    $string=explode(".",$string);
    $string=$string[0].$string[1];
    $rma_number=$string;
    
    $sql12345="SELECT * FROM $tbl_name4 WHERE rma_number=$rma_number";
    $result12345=mysql_query($sql12345);
    $num_rows12345=mysql_num_rows($result12345);
    }
    while($num_rows12345 < 1){
    $sql2000000="UPDATE $tbl_name4 SET rma_number='$rma_number', rma_name='$rma_name' WHERE rma_id = $rma_id";
    mysql_query($sql2000000);
    }
    

  8. You don't have to use my example EXACTLY, it could easily be done without username.

     

    You'd need some sort of unique seed to it though, perhaps by using an auto_increment value that was tied to the original purchase?

     

    Your final code there is completely random, so there's nothing to stop duplicate entries from existing.

     

    won't microtime(true) always generate a incremented number based on when the rma issued? I don't see how there would be duplicates if the microtime is always incrementing and will never repeat in the foreseeable future.

  9. For some reason I can't start a new topic in this sub-forum.... so I'm going to have to hi-jack this thread.

     

    I'm trying to set-up a cron job to execute a php script.

     

    The Cron Job Command I have right now:

     

    /usr/bin/php -f /home/zyquo/public_html/ghosthuntersportal.com/cj_run.php

     

    Is that even remotely correct?

     

    As of right now it's not running at all.

  10. $sql="SELECT * FROM $tbl_name3 WHERE review_show='n'";
    $result=mysql_query($sql);
    $num_results=mysql_num_rows($result);
    if($num_results > 1){
    $message="You have ".$num_results." reviews unapproved.";
    mail('example@example.com','GHP Reviews', $message, 'From: example@example.com');
    }
    
    $sql2="SELECT * FROM $tbl_name4 WHERE rma_issued='n'";
    $result2=mysql_query($sql2);
    $num_results2=mysql_num_rows($result2);
    if($num_results2 > 1){
    $message="You have ".$num_results2." RMA Numbers Requested.";
    mail('example@example.com','GHP RMA Number Requests', $message, 'From: example@example.com');
    }
    

     

    The reviews email is being sent, however, the RMA email is not.

     

    EDIT: Nevermind, $num_results and $num_results2 should have been > 0 not > 1.

  11. Found the issue...

     

    I killed the session on index.php at the bottom of the page... rma.php (the one with the form) is included into index.php. Index.php is basically the layout of the site, while rma.php is the content for ?returns=rma. So $_SESSION['submitted'] was being killed before it was even sent to the next page.

  12. Tested your code and it works fine... only had to add in a few lines of code to properly parse the $_GET['error'] into the $error array. I suppose you have omitted that from the code you posted?

     

    Nope, the $error variable is working as I have it in the code posted.

     

     

    var_dump returns:

     

    array(9) { ["name"]=> string(4) "test" ["email"]=> string(16) "test@exmaple.com" ["confirm_email"]=> string(16) "test@example.com" ["phone"]=> string(12) "123123123123" ["ext"]=> string(0) "" ["month"]=> string(2) "12" ["day"]=> string(2) "12" ["year"]=> string(4) "1212" ["products_returning"]=> string(46) "asdfasdfsadfswdfsadfasfasfsafdasdfasdfasdfasdf" } 
    

  13. You did not declare $_SESSION['submitted']. I doubt you want to store a $_SESSION['submitted'], so I would suggest trying

     

    if($_POST['submitted']=="yes"){

     

    Instead of

    if($_SESSION['submitted']=="yes"){

     

    I did in the first page:

     

    $_SESSION['submitted']="yes";

     

    Just below session_start();

     

    I'm trying to use hidden inputs as little as possible. I removed the <input type="hidden"> tag.

  14. The below is flagging errors #3 and #9. Error #3 is being thrown even though the emails match.

     

    <?php
    session_start();
    $_SESSION['submitted']="yes";
    $error=$_GET['error'];
    $date_rma="5/10/2011";
    $content='
    <div class="content_text">
    <div class="content_header">Request RMA Number</div>
    <p>Enter the information you used on PayPal, that you completed your order with. The information must match, or a RMA Number will not
    be issued.</p>
    <form action="./rma_process.php" method="post">
    <p><label>Name:</label> <input type="text" name="name" size="30" 
    value="'.(isset($_SESSION['name']) ? $_SESSION['name'] : '').'" />';
    if($error[0]==1){ $content.=' <span class="red bold">This field is required.</span>'; }
    $content.='</p>
    <p><label>E-Mail Address:</label> <input type="email" name="email" size="35" 
    value="'.(isset($_SESSION['email']) ? $_SESSION['email'] : '').'" />';
    if($error[1]==1){ $content.=' <span class="red bold">This field is required.</span>'; }
    $content.='</p>
    <p><label>Confirm E-Mail Address:</label> <input type="email" name="confirm_email" size="35" 
    value="'.(isset($_SESSION['confirm_email']) ? $_SESSION['confirm_email'] : '').'" />';
    if($error[2]==1){ $content.=' <span class="red bold">This field is required.</span>'; }
    if($error[3]==1){ $content.=' <span class="red bold">E-Mail addresses do not match.</span>'; }
    $content.='</p>
    <p><label>Phone Number:</label> <input type="text" name="phone" size="15" 
    value="'.(isset($_SESSION['phone']) ? $_SESSION['phone'] : '').'" /> 
    Ext. <input type="text" name="ext" size="4" 
    value="'.(isset($_SESSION['ext']) ? $_SESSION['ext'] : '').'" />';
    if($error[4]==1){ 
    $content.=' <span class="red bold">A properly formatted phone number is required.</span>'; }
    $content.='</p>
    <p><label>Date of Purchase (MM/DD/YYYY):</label><input type="text" name="month" size="2" maxlength="2" 
    value="'.(isset($_SESSION['month']) ? $_SESSION['month'] : '').'" />
    <input type="text" name="day" size="2" maxlength="2" 
    value="'.(isset($_SESSION['day']) ? $_SESSION['day'] : '').'" /> 
    <input type="text" name="year" size="5" maxlength="4"  
    value="'.(isset($_SESSION['year']) ? $_SESSION['year'] : '').'" />';
    if($error[5]==1 || $error[6]==1 || $error[7]==1){ 
    $content.=' <span class="red bold">A properly formatted date is required.</span>'; }
    $content.='</p><p><label>List the Products you wish to return. Sperate with a comma. <br />Use either the whole product name, or the GHP# Product Code:</label>';
    if($error[8]==1){ $content.=' <span class="red bold">This field is required.</span>'; }
    $content.='<textarea name="products_returning" rows="10" cols="60">
    '.(isset($_SESSION['products_returning']) ? $_SESSION['products_returning'] : '').'';
    $content.='
    </textarea>
    <input type="hidden" name="submitted" value="yes" />
    </p>
    <p><input type="submit" value="Submit" name="Submit" /></p>
    </form>
    </div>
    ';
    ?>
    

     

    <?php
    session_start();
    $name = $_POST['name'];
    $_SESSION['name']=$name;
    if($name==""){
    $error0=1;
    }
    else{
    $error0=0;
    }
    
    $email = $_POST['email'];
    $_SESSION['email']=$email;
    if($email==""){
    $error1=1;
    }
    else{
    $error1=0;
    }
    
    $confirm_email = $_POST['confirm_email'];
    $_SESSION['confirm_email']=$confirm_email;
    if($confirm_email==""){
    $error2=1;
    }
    else{
    $error2=0;
    }
    
    if($email!=$confirm_email){
    $error3=1;
    }
    else{
    $error3=0;
    }
    
    $phone = $_POST['phone'];
    $_SESSION['phone']=$phone;
    if($phone==""){
    $error4=1;
    }
    else{
    $error4=0;
    }
    
    $ext = $_POST['ext'];
    $_SESSION['ext']=$ext;
    
    $phone = $phone.' Ext.'.$ext;
    
    $month = $_POST['month'];
    $_SESSION['month']=$month;
    if($month=="" || !is_numeric($month)){
    $error5=1;
    }
    else{
    $error5=0;
    }
    
    $day = $_POST['day'];
    $_SESSION['day']=$day;
    if($day=="" || !is_numeric($day)){
    $error6=1;
    }
    else{
    $error6=0;
    }
    
    $year = $_POST['year'];
    $_SESSION['year']=$year;
    if($year=="" || !is_numeric($year)){
    $error7=1;
    }
    else{
    $error7=0;
    }
    
    $date="".$month."/".$day."/".$year."";
    
    $products_returning = $_POST['products_returning'];
    $_SESSION['products_returning']=$products_returning;
    if($products_returning==""){
    $error8=1;
    }
    else{
    $error8=0;
    }
    
    if($_SESSION['submitted']=="yes"){
    $error9=0;
    }
    else{
    $error9=1;
    }
    
    
    $error="".$error0."".$error1."".$error2."".$error3."".$error4."".$error5."".$error6."".$error7."".$error8."".$error9."";
    
    if($error!=="0000000000"){
    header("Location: ./index.php?returns=rma&error=".$error0."".$error1."".$error2."".$error3."".$error4."".$error5."".$error6."".$error7."".$error8."".$error9."");
    }
    else{
    header("Location: ./index.php?returns=submitted");
    }
    ?>
    

  15. <?php
    $length = 2;
    $characters = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
    $string ="";
    $string.= microtime(true);
    for ($p = 0; $p < $length; $p++) {
    $string .= $characters[mt_rand(0, strlen($characters))];
    }
    $string= substr_replace($string, '', 0, 4);
    for ($p = 0; $p < $length; $p++) {
    $string2 .= $characters[mt_rand(0, strlen($characters))];
    }
    $string="".$string2."".$string;
    $string=explode(".",$string);
    $string=$string[0].$string[1];
    echo $string;
    ?>
    

     

  16. I hate to keep posting (wish I could a edit for a little while longer), but I came up with this:

     

    <?php
    <?php
    $length = 2;
    $characters = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
    $string ="";
    $string.= time();
    $string.= substr($string, 2);
    for ($p = 0; $p < $length; $p++) {
    $string .= $characters[mt_rand(0, strlen($characters))];
    }
    echo $string;
    ?>
    

     

     

    The issue is it seems the substr is not removing the first to characters (the "13" from the unix time stamp), it's making the whole string longer. I want to remove the "13" and add an additional 2 random characters on front.

  17. The issue with some of these Ideas is I don't have user accounts. I'm not handling any of the payment processing, or cart processing... I'm using PayPal.

     

    I came up with this idea:

     

    <?php
    do {
    $test=base_convert(mt_rand(0x19A100, 0x39AA3FF), 10, 36);
    $test.=mt_rand(0000001, 9999999);
    } 
    while (mysql_query("INSERT INTO ... ") != SUCCESS);
    echo $test;
    ?>
    

    And using a Unique row in the table for the RMA numbers.

     

    Don't know how viable that is though. I've never used Do-While before, so I could be using it completely wrong. The idea of running a second table with all the RMAs already created could be another option.

  18. I need a way to generate a random number and insert into a database, and I need the database to not contain any duplicates of that number. I basically need to generate a RMA # (Return Merchandise Authorization Number), so the numbers absolutely CAN NOT be duplicate. I have no ideas how to go about this.

     

    Should I generate a random number, search the database and see if there's a duplicate, and if there is re-run the script?

×
×
  • 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.