Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



Reply
Confusion about JavaScript confirmation
Old 10-11-2006, 03:24 PM Confusion about JavaScript confirmation
Novice Talker

Posts: 6
Name: Rusty
Trades: 0
I have a particular question, hopefully I can describe it well enough to set some help.

I am running a site that has downloads. The clients want a user to enter their email address before they can access any of the downloads. Right now I have a script ready that checks if the email address has the valid characters and such, but I don't know how to make the user enter their e-mail before they can get the downloads.

In other words, I want the links for the downloads to be "turned off", in a sense, until their e-mail is entered. After they submit that all of the downloads will be available to them.

I'd appreciate any ideas you could have. Thanks

Rusty, aka 'HiRiser99'
HiRiser99 is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 10-11-2006, 09:36 PM Re: Confusion about JavaScript confirmation
reli4nt's Avatar
Extreme Talker

Posts: 168
Location: New York
Trades: 0
Your best bet may simply be to collect the email address and then create a session variable for it. Then on the downloads page simply check to see if the user has the session variable set and if they do not simply redirect them to a page inviting them to enter their email address.

If you store the email in a database simply check for duplicate entries everytime you attempt to enter a new entry.

Note: This will not prevent them from saving the link to the direct dowload. To avoid this you can have the link to the actual file be a php script that checks for the session variable and uses header() to redirect to the page requiesting the email or uses header() to call the file to download. This way the download url is never truly revealed.
__________________

Please login or register to view this content. Registration is FREE

Designing the world we live in.
Defining the terms we live by.
reli4nt is offline
Reply With Quote
View Public Profile Visit reli4nt's homepage!
 
Old 10-16-2006, 02:21 AM Re: Confusion about JavaScript confirmation
seomumbai's Avatar
Skilled Talker

Posts: 98
Trades: 0
The best thing that you can do is to hide the dowload link and display it as the user enters the E-mail ID. Then u chek for the email address and then display the Download link which he had selected before.

And check that E-mail Address is correct or not through Regularexpressions.
seomumbai is offline
Reply With Quote
View Public Profile
 
Old 10-16-2006, 05:33 PM Re: Confusion about JavaScript confirmation
Novice Talker

Posts: 6
Name: Rusty
Trades: 0
Thanks for the input, unfortunately I don't know much about PHP right now. I forgot to mention that the email addresses will go to email (as of now, not very much traffic).

I have another method of retrieving the email, but I'm having a tough time with the execution.

What I am attempting to do now is make a new confirmation page, where the user can enter their email address. There will be a submit button that will (after some email validation) obviously submit the user's email address to our account.

But how would I redirect them to the downloads page? And can I call that from the FORM tag in the HTML doc?

I hope this isn't too broad, I found a script off the web for the email check, but I can't seem to create a function that will validate the email along with a redirect.

Again, thanks for the responses.

HiRiser99
HiRiser99 is offline
Reply With Quote
View Public Profile
 
Old 10-16-2006, 08:31 PM Re: Confusion about JavaScript confirmation
mgraphic's Avatar
Truth Seeker

Latest Blog Post:
JAMISONTUNES
Posts: 2,898
Name: Keith Marshall
Location: Connecticut
Trades: 0
You are going to need some kind of server-side scripting to make this work correctly, because javascript alone would make it too easy to be hacked.
__________________

<mgraphic /> - I don't have a solution but I admire the problem.
mgraphic is offline
Reply With Quote
View Public Profile
 
Old 10-26-2006, 05:15 PM Re: Confusion about JavaScript confirmation
Novice Talker

Posts: 6
Name: Rusty
Trades: 0
Quote:
Originally Posted by mgraphic View Post
You are going to need some kind of server-side scripting to make this work correctly, because javascript alone would make it too easy to be hacked.
That is sound logic. With that in mind I have shifted away from Javascript for a moment to try another plan of action.

I have tried to implement some php to process the form data from HTML. I am going to process by taking the email and appending it to a file. Each time an email is sent the new address gets added with the previous entries. After a certain time I will send it off to my client's email address. Does that make sense?

HTML form data (email) ---> php script to save to a file ---> send the file off after a collection of emails is made.

Can I append to a file in php? Like this:
Code:
<?php $email = $_POST ['eEntry'];
  $file = fopen ('newEmails.txt', 'a+');
  echo $email;
  fclose ($file);
 echo '<h1 align=center>Email Submission Completed</h1>';
?>
Where eEntry would be the user defined email from the HTML. I change it to a session variable $email and newEmails.txt will be the file I want to append to.

Is that the correct syntax?

At this point I guess I want this to work first before I worry about confirmation. I see I can use JavaScript as a client-side confirmation (with a confirm box, etc) but I want to get this working.

Last edited by HiRiser99; 10-26-2006 at 05:37 PM..
HiRiser99 is offline
Reply With Quote
View Public Profile
 
Old 10-27-2006, 12:16 AM Re: Confusion about JavaScript confirmation
mgraphic's Avatar
Truth Seeker

Latest Blog Post:
JAMISONTUNES
Posts: 2,898
Name: Keith Marshall
Location: Connecticut
Trades: 0
I have built a php function that forces the fckeditor input into xhtml strict compliant code. You are free to use it, but there are a few UDF functions that you will need to strip out.

PHP Code:
//###  Clean $_REQUEST input created by FCK Editor and prepare it for db insertion
  
function clc_fck_cleanup($html) {
    if (!
clc_not_null($html)) return '';
    
$skip = array('script''form''input''textarea''button''option''select');
    
$non_closing = array('br''hr''img');
    
$font_size = array('1' => 'xx-small''2' => 'x-small''3' => 'small''4' => 'medium''5' => 'large''6' => 'x-large''7' => 'xx-large');
    
$font_family_add 'verdana, arial, sans-serif';
    
$html preg_replace('/(<\/?)(\w+)([^>]*)(>)/e''strtolower("$1$2$3$4")'stripslashes($html));
    
preg_match_all('/<(\/?\w+)([^>]*)>([^<]+)?/'$html$tagsPREG_SET_ORDER);
    
$output '';
    for(
$i 0$i count($tags); $i++) {
      if (!
in_array($tags[$i][1], $skip)) {
        
preg_match_all('/(\w+)="([^"]*)"/'trim($tags[$i][2]), $attPREG_SET_ORDER);
        
$natt = array();
        
$class = array();
        
$style = array();
        
//###  Rebuild tag name
        
switch ($tags[$i][1]) {
          case 
'font':
            
$ntag 'span';
            break;
          case 
'/font':
            
$ntag '/span';
            if (!
in_array('span'$non_closing)) $non_closing[] = 'span';
            break;
          default:
            
$ntag trim($tags[$i][1]);
            break;
        }
        for(
$a 0$a count($att); $a++) {
          if (!
preg_match('/^on.*$/'$att[$a][1]) && !preg_match('/javascript/'$att[$a][2])) switch ($att[$a][1]) {
            case 
'class':
              foreach(
explode(' '$att[$a][2]) as $value$class[] = $value;
              break;
            case 
'style':
              foreach(
explode(';'$att[$a][2]) as $value$style[] = $value;
              break;
            case 
'align':
              
$class[] = $att[$a][2];
              break;
            case 
'face':
              
$style[] = 'font-family: ' $att[$a][2] . ', ' $font_family_add;
              break;
            case 
'size':
              if (
$tags[$i][1] == 'font'$style[] = 'font-size: ' $font_size[$att[$a][2]];
              break;
            case 
'color':
              if (
$tags[$i][1] == 'font'$style[] = 'color: ' $att[$a][2];
              break;
            default:
              
$natt[$att[$a][1]] = $att[$a][2];
              break;
          }
        }
        
$natt['class'] = implode(' '$class);
        
$natt['style'] = implode('; '$style);
        if (
$nc count($natt) > 0) {
          
$n 0;
          
$ntag .= ' ';
          foreach(
$natt as $key => $value) {
            if ( 
$key == 'alt' XOR (clc_not_null($value)) ) $ntag .= ' ' $key '="' $value . ( ($key == 'style') ? ';' '' ) . '"';
            if (
$n $nc && clc_not_null($value)) $ntag .= ' ';
          }
        }
        
$output .= '<' trim($ntag);
        if (
in_array($tags[$i][1], $non_closing)) $output .= ' /';
        
$output .= '>';
        
$output .= $tags[$i][3];
      } else {
        
$output .= $tags[$i][3];
      }
    }
    return 
clc_output_string($outputfalsetrue);
  } 
__________________

<mgraphic /> - I don't have a solution but I admire the problem.
mgraphic is offline
Reply With Quote
View Public Profile
 
Old 10-27-2006, 07:54 PM Re: Confusion about JavaScript confirmation
Novice Talker

Posts: 6
Name: Rusty
Trades: 0
Code:
<html>
 <head>
  <title>Globe Radio Email Submission Page</title>
<script language="javascript">
function eCheck() 
{
    if (document.eForm.eEntry.value.length == 0 || document.eForm.eEntry.value.length < 8) 
    {
        alert("Enter your valid eMail address in the first field.");
        return false;
    }
     else if (document.eForm.eConfirm.value.length == 0 || document.eForm.eConfirm.value.length < 8)
    {
        alert("Enter your valid eMail address in the second field.");
        return false;
    }
    else if (document.eForm.eEntry.value != document.eForm.eConfirm.value) 
    {
        alert("Your eMails do not match.  Make sure both eMails match and resend..");
        return false;
    }
    return true;
 
}
</script>
 </head>
 <body>
<h4>You need to enter a valid email address to access the Globe Radio Archives.</h4>
<form name = "eForm" method="post" action=".../new-email.php" >
  <input type = "text" name = "eEntry" id = "eEntry" value = "" size = "25" maxlength="40"> <br />
<h4>Enter your email address again to confirm.</h4>
  <input type = "text" name = "eConfirm" id = "eConfirm" value="" size = "25" maxlength="40"> <br />
  <input type = "submit" name="submit-eEntry" value="Submit" onSubmit="return eCheck();">
</body>
</html>
This isn't working for me. Even with this check, the form is continuing on to the downloads page. It doesn't even acknowledge my javascript. Am I doing something wrong with this?

Last edited by HiRiser99; 10-31-2006 at 07:28 PM.. Reason: Can't figure out what's wrong with this logic. This should work.
HiRiser99 is offline
Reply With Quote
View Public Profile
 
Old 10-31-2006, 07:24 PM Re: Confusion about JavaScript confirmation
Novice Talker

Posts: 6
Name: Rusty
Trades: 0
I edited my previous post to show my html page with the javaascirpt included. As I said before, the javascript is not doing any checks on the emails. The form data is getting processed without the javascript.

Is there anything syntactically or logically wrong with the code?

Thanks for the help so far

Rusty aka HiRiser99
HiRiser99 is offline
Reply With Quote
View Public Profile
 
Old 11-09-2006, 04:31 AM Re: Confusion about JavaScript confirmation
seomumbai's Avatar
Skilled Talker

Posts: 98
Trades: 0
I think the best to implemnt this is to first disable the links and when the user enters the email address and clicks the submit button then you enable the links and then the user can access the links.
seomumbai is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Confusion about JavaScript confirmation
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.44217 seconds with 12 queries