Avatar billede rune-boege Nybegynder
10. juni 2006 - 20:12 Der er 1 kommentar og
1 løsning

Problemer hælp..

Ok dette her er en side ligesom hotscripts.com jeg er ved at kode.
Men jeg kan ikke se hvad jeg har gjort galt, den virkede da jeg havde den på engelsk, men den virker ikke nu på dansk.

Koden ses herunder:

Signup.php
_______________
<?
include_once "config.php";
include_once "left_index.php";
include_once "right_index.php";

function main()
{
////////////////////////////INSERTS MEMBER INFORMATION  INTO DB and sets session so as to automatically login the member . ALSO sends a welcome mail ////////////////

function perform_insert()
{

mysql_query ("delete from sbwmd_signups where email='" . $_REQUEST["email"]. "'");



$rnum =  mt_rand(1,1000000000);
$insert_str="Insert into `sbwmd_signups` ( email ,rnum,onstamp) VALUES ( " ."'".str_replace("'","''",$_REQUEST["email"])."'" ."," ."'". $rnum ."'," . date("Ymdhis",time()) . ")";
mysql_query($insert_str);

///////////////////////////////////////////////////////////////////////
///////////////////////////// SEND EMAIL //////////////////////////////
$rs0=mysql_fetch_array(mysql_query("select * from sbwmd_config"));
$link= $rs0["site_addrs"] . "/signup1.php?email=" . $_REQUEST["email"] . "&rnum=" . $rnum ;

$sql = "SELECT * FROM sbwmd_mails where id=6" ;
$rs_query=mysql_query($sql);

if ( $rs=mysql_fetch_array($rs_query)  )
  {
            $from =$rs["fromid"];

            $to = $_REQUEST["email"];

            $subject =$rs["subject"];

            $header="From:" . $from . "\r\n" ."Reply-To:". $from  ;

            $body=str_replace("<link>", $link,str_replace("<email>", $_REQUEST["email"],$rs["mail"]) );
           
            mail($to,$subject,$body,$header);

}
//////////////////////////////// CONFIRMATION SENT//////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////


}
//////////////Function perform_insert ends here/////////

$errcnt=0;
$showform="";

$email="";

//IF SOME FORM WAS POSTED DO VALIDATION
if ( count($_POST)<>0 )
{
$email=$_REQUEST["email"];

if ( !isset( $_REQUEST["email"] ) || $_REQUEST["email"]=="" )
{
    $errs[$errcnt]="Email must be provided";
    $errcnt++;
}


if ( isset( $_REQUEST["email"] ) )
{
$rs0_query=mysql_query ("select * from sbwmd_members where email='" . $_REQUEST["email"]. "'");
if ($rs0=mysql_fetch_array($rs0_query))
{
    $errs[$errcnt]="Some member has already registered with this email id. <br>So, you cannot register with this email id";
    $errcnt++;

}
}


}
//Array of errors have been generated



?>
<html>
<head>
<title>Member Signup</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
<?
if  (count($_POST)<>0)
{

if ( $errcnt==0 )
{
perform_insert();
?>
<br>
<br>
<table width="80%" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td><div align="justify"><strong><font color="#FF0000" size="2" >Godkend venligst denne email, f&oslash;r kan du ikke oprette en bruger.. </font></strong></div></td>
  </tr>
</table>
<strong></strong>
<?
$showform="No";
}
else
{
?>
<table width="80%" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td colspan="2">&nbsp;</td>
  </tr>
  <tr>
    <td colspan="2"><font color="#FF0000" size="2" ><strong>Der er sket en fejl, fejlen er: </strong></font></td>
  </tr>
  <?

for ($i=0;$i<$errcnt;$i++)
{
?>
  <tr valign="top">
    <td width="6%"><strong><font color="#FF0000"><?php echo $i+1; ?></font></strong></td>
    <td width="94%"><font color="#FF0000" size="2" ><?php echo  $errs[$i]; ?>
      </font></td>
  </tr>
  <?
}
?>
</table>

<?

}

}

if ($showform<>"No")
{
?>
<form name="form1" method="post" action="signup.php">
  <br>
  <table width="95%" border="0" align="center" cellpadding="4" cellspacing="0">
    <tr>
      <td><font color="#FFFFFF" size="2" ><a href="index.php"><font color="#FFFFFF" size="2" face="Verdana, Arial, Helvetica, sans-serif"><strong><font color="#000000">HJEM</font></strong></font></a>
        <strong><font color="#000000" size="2" >&gt; OPRET BRUGER </font></strong></font>
        <hr size="1"></td>
    </tr>
    <tr>
      <td bgcolor="#FFFFFF"><div align="center">
          <table width="71%" border="0" align="center" cellpadding="4" cellspacing="0" background="images/greypixel.gif">
            <tr>
              <td colspan="3" valign="top" bgcolor="#FFFFFF"><font color="#FFFFFF" size="2" ><strong><font color="#000000">Skriv venligst din email for at fors&aelig;tte til valideringen </font>ue...</strong></font></td>
            </tr>
            <tr>
              <td valign="top">&nbsp;</td>
              <td valign="top">&nbsp;</td>
              <td>&nbsp;</td>
            </tr>
            <tr>
              <td valign="top"><div align="right"><strong><font color="#FF0000">*</font>
                  Din Email:</strong></font></div></td>
              <td valign="top">&nbsp;</td>
              <td>&nbsp;
                <input name="email" type="text" class=select size="30" maxlength="40">
                </font></td>
            </tr>
            <tr>
              <td valign="top">&nbsp;</td>
              <td valign="top">&nbsp;</td>
              <td><font color="#666666" size="1" >Din gamle anmodning vil blive slettet hvis du sender en ny. </font></td>
            </tr>
          </table>
          <input type="submit" name="Submit" value="Continue" class="input">
          <br>
        </div></td>
    </tr>
  </table>
  <br>
</form>
<?
} //If showform = No? ends here
}
include "template.php";
?>

____
Her skal brugeren først skrive sin e-mail, og scriptet sender den email til ens mail. hvorefter man skal klikke på et link, for at gå videre til selve oprettelsen af kontoen.

_______
signup1.php
_______

<?
include_once "config.php";
include_once "left_index.php";
include_once "right_index.php";

function main()
{
/////////////getting length of user name and password
$len=mysql_fetch_array(mysql_query("select username_len,pwd_len from sbwmd_config"));
$username_len=$len["username_len"];
$pwd_len=$len["pwd_len"];
?>

<SCRIPT language=javascript>
<!--
function emailCheck (emailStr) {
var emailPat=/^(.+)@(.+)$/
var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]"
var validChars="\[^\\s" + specialChars + "\]"
var quotedUser="(\"[^\"]*\")"
var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/
var atom=validChars + '+'
var word="(" + atom + "|" + quotedUser + ")"
var userPat=new RegExp("^" + word + "(\\." + word + ")*$")
var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$")
var matchArray=emailStr.match(emailPat)
if (matchArray==null) {
    alert("Email address seems incorrect (check @ and .'s)")
    return false
}
var user=matchArray[1]
var domain=matchArray[2]
if (user.match(userPat)==null) {
    alert("The username doesn't seem to be valid.")
    return false
}
var IPArray=domain.match(ipDomainPat)
if (IPArray!=null) {
    // this is an IP address
      for (var i=1;i<=4;i++) {
        if (IPArray[i]>255) {
            alert("Destination IP address is invalid!")
        return false
        }
    }
    return true
}
var domainArray=domain.match(domainPat)
if (domainArray==null) {
    alert("The domain name doesn't seem to be valid.")
    return false
}
var atomPat=new RegExp(atom,"g")
var domArr=domain.match(atomPat)
var len=domArr.length
if (domArr[domArr.length-1].length<2 ||
    domArr[domArr.length-1].length>3) {
  alert("The address must end in a three-letter domain, or two letter country.")
  return false
}
if (len<2) {
  var errStr="This address is missing a hostname!"
  alert(errStr)
  return false
}
return true;
}


  function formValidate(form) {
    if ( form.company_contact.value == "" ) {
            alert('Company contact is required!');
      return false;
      }
        if(!form.email_addr.value.match(/[a-zA-Z\.\@\d\_]/)) {
          alert('Invalid e-mail address.');
          return false;
          }

if (!emailCheck (form.email_addr.value) )
{
    return (false);
}

 
        if(form.stadd1.value == ""){
      alert('Street address 1 is required.');
          return false;
          }
        if(form.city.value == ""){
      alert('City is required.');
          return false;
          }
        if(form.zip_code.value == ""){
      alert('Zip/postal code is required.');
          return false;
          }
        if(form.country.selectedIndex == 0){
      alert('Country is required.');
          return false;
          }
        if(form.state_province_non.value == "" && form.state_province.selectedIndex == 0){
          alert('You must specify a state for U.S. or state/province for non U.S.');
          return false;
          }
        if(form.phone_number.value == ""){
      alert('Phone number is required.');
          return false;
          }
   
        if (form.username.value == "") {
      alert('Username is required.');
      return false;
      }
      if (form.username.value.length<'<? echo $username_len?>') {
      alert('Username must be greater than <? echo $username_len;?> characters.');
      return false;
      }
  if (form.pwd.value == "") {
      alert('Password is required.');
      return false;
      }
  if (form.pwd.value.length<'<? echo $pwd_len?>') {
      alert('Password must be more than <? echo $pwd_len;?>  characters long.');
      return false;
      }       
    if (form.pwd.value != form.pwd2.value)
    {
        alert('Passwords do not match.');
        return false;
    }

        if(form.agreement_conf[1].checked) {
          alert(' You must agree to the Registration Agreement');
          return false;
          }
    return true;
  }
// -->
</SCRIPT>
<table width="430" border="0" align="center" cellpadding="5" cellspacing="0">
  <tr>
    <td></td>
  </tr>
  <tr>
    <td height="25"> <a href="index.php"><font color="#FFFFFF" size="2" face="Verdana, Arial, Helvetica, sans-serif"><strong><font color="#000000">HJEM</font></strong></font></a>
      <strong><font color="#000000" size="2" >&gt; OPRET BRUGER </font></strong>
      <hr size="1"></td>
  </tr>
  <tr>
    <td>
      <?
if ( isset($_REQUEST["msg"])&&$_REQUEST['msg']<>"")
{
?>
      <br> <table align="center" bgcolor="#FEFCFC"  border="0" cellpadding="5" >
        <tr>
          <td><b><font face="verdana, arial" size="1" color="#666666">
            <?
print($_REQUEST['msg']);

?>
            </font></b></td>
        </tr>
      </table>
      <?
}//end if

$invalidaccess="No";
if( !isset($_REQUEST["rnum"]) || !isset($_REQUEST["email"] ) )
{
$invalidaccess="Yes";
}
else
{
$rs0_query=mysql_query ("select * from sbwmd_signups where email='" . $_REQUEST["email"]. "' and rnum='" . $_REQUEST["rnum"]. "' ");
if ($rs0=mysql_fetch_array($rs0_query))
{}else
{
$invalidaccess="Yes";
}
}
if ($invalidaccess=="Yes")
{
?>
      <table align="center" bgcolor="#FEFCFC"  border="0" cellpadding="5" >
        <tr>
          <td><div align="center"><b><font face="verdana, arial" size="1" color="#666666">
            Invalid
          </font></b></div></td>
        </tr>
      </table>
      <?
}
else
{
?>
      <FORM name=register onsubmit=return(formValidate(this));
                  method=post action="insertmember.php">
        <TABLE class="onepxtable" cellSpacing=1 cellPadding=1 width=400 border=0>
          <TBODY>
            <TR>
              <TD width="200" height="25" align=left valign="top" bgcolor="#f4f4f4">&nbsp;<B>Firma navn </B></TD>
              <TD align=right>&nbsp;</TD>
              <TD><INPUT style="FONT-FAMILY: Tahoma, Arial, Verdana"
                        maxLength=120 size=25 name=company_name></TD>
            </TR>
            <TR>
              <TD width="200" height="25" align=left valign="top" bgcolor="#f4f4f4">&nbsp;<B>Firma kontakt </B></TD>
              <TD align=right><FONT color=red
                        size=1>*&nbsp;</FONT></TD>
              <TD><INPUT style="FONT-FAMILY: Tahoma, Arial, Verdana"
                        maxLength=120 size=25 name=company_contact></TD>
            </TR>
            <TR>
              <TD width="200" height="25" align=left valign="top" bgcolor="#f4f4f4">&nbsp;<B>Din adresse 1 </B></TD>
              <TD align=right><FONT color=red
                        size=1>*&nbsp;&nbsp;</FONT></TD>
              <TD><INPUT style="FONT-FAMILY: Tahoma, Arial, Verdana"
                        maxLength=120 size=35 name=stadd1></TD>
            </TR>
            <TR>
              <TD width="200" height="25" align=left valign="top" bgcolor="#f4f4f4">&nbsp;<b>Din adresse 2 </b></TD>
              <TD align=right>&nbsp;</TD>
              <TD><INPUT style="FONT-FAMILY: Tahoma, Arial, Verdana"
                        maxLength=120 size=30 name=stadd2></TD>
            </TR>
            <TR>
              <TD width="200" height="25" align=left valign="top" bgcolor="#f4f4f4">&nbsp;<B>By</B></TD>
              <TD align=right><FONT color=red
                        size=1>*&nbsp;&nbsp;</FONT></TD>
              <TD><INPUT style="FONT-FAMILY: Tahoma, Arial, Verdana"
                        maxLength=120 size=30 name=city></TD>
            </TR>
            <TR>
              <TD width="200" height="25" align=left valign="top" bgcolor="#f4f4f4">&nbsp;<B>Sted [jylland, kb, etc]</B></TD>
              <TD vAlign=center align=right><FONT color=red
                        size=1>*&nbsp;</FONT> </TD>
              <TD><INPUT style="FONT-FAMILY: Tahoma, Arial, Verdana"
                        name=state_province_non></TD>
            </TR>
            <TR>
              <TD width="200" height="25" align=left valign="top" bgcolor="#f4f4f4">&nbsp;<B>Postkode</B></TD>
              <TD align=right><FONT color=red
                        size=1>*&nbsp;</FONT></TD>
              <TD><INPUT style="FONT-FAMILY: Tahoma, Arial, Verdana"
                        maxLength=11 size=15 name=zip_code></TD>
            </TR>
            <TR>
              <TD width="200" height="25" align=left valign="top" bgcolor="#f4f4f4">&nbsp;<B>Land</B></TD>
              <TD align=right><FONT color=red
                        size=1>*&nbsp;&nbsp;</FONT></TD>
              <TD><INPUT style="FONT-FAMILY: Tahoma, Arial, Verdana"
                        maxLength=20 size=15 name=phone_number> </TD>
            </TR>
            <TR>
              <TD width="200" height="25" align=left valign="top" bgcolor="#f4f4f4">&nbsp;<B>Tlf. nummer </B></TD>
              <TD align=right><FONT color=red
                        size=1>*&nbsp;</FONT></TD>
              <TD><INPUT style="FONT-FAMILY: Tahoma, Arial, Verdana"
                        maxLength=20 size=15 name=phone_number></TD>
            </TR>
            <TR>
              <TD width="200" height="25" align=left valign="top" bgcolor="#f4f4f4">&nbsp;<B>Fax
                nummer</B></TD>
              <TD align=right>&nbsp;</TD>
              <TD><INPUT style="FONT-FAMILY: Tahoma, Arial, Verdana"
                        maxLength=20 size=15 name=fax_number></TD>
            </TR>
            <TR>
              <TD width="200" height="25" align=left valign="top" bgcolor="#f4f4f4">&nbsp;<B>E-mail
                addresse</B></font></TD>
              <TD align=right><FONT color=red
                        size=1>*&nbsp;</FONT></TD>
              <TD><INPUT style="FONT-FAMILY: Tahoma, Arial, Verdana"
                        maxLength=99 size=25 name=email_addr readonly value="<?php echo $_REQUEST["email"] ?>"></TD>
            </TR>
            <TR>
              <TD width="200" height="25" align=left valign="top" bgcolor="#f4f4f4">&nbsp;<B>hjemmeside URL </B></font></TD>
              <TD align=right>&nbsp;</TD>
              <TD><INPUT
                        style="FONT-FAMILY: Tahoma, Arial, Verdana"
                        maxLength=255 size=30 value=http://
name=home_page></TD>
            </TR>
            <TR>
              <TD width="200" height="25" align=left valign="top" bgcolor="#f4f4f4">&nbsp;<B>Brugernavn</B></font></TD>
              <TD align=right><FONT color=red
                        size=1>*&nbsp;</FONT></TD>
              <TD><INPUT style="FONT-FAMILY: Tahoma, Arial, Verdana"
                        maxLength=20 size=15 name=username> &nbsp;</font></TD>
            </TR>
            <TR>
              <TD height="25" align=left valign="top" bgcolor="#f4f4f4">&nbsp;<b>Kodeord</b></TD>
              <TD align=right><FONT color=red
                        size=1>*&nbsp;</FONT></TD>
              <TD><INPUT type=password style="FONT-FAMILY: Tahoma, Arial, Verdana"
                        maxLength=20 size=15 name=pwd> &nbsp;</font></TD>
            </TR>
            <TR>
              <TD height="25" align=left valign="top" bgcolor="#f4f4f4">&nbsp;<B>Bekr&aelig;ft</B></TD>
              <TD align=right><FONT color=red
                        size=1>*&nbsp;</FONT></TD>
              <TD><INPUT type=password style="FONT-FAMILY: Tahoma, Arial, Verdana"
                        maxLength=20 size=15 name=pwd2> &nbsp;</font></TD>
            </TR>
            <TR>
              <td bgcolor="#f4f4f4"><b>&nbsp;Modtag tilbud fra andre selskaber .</b> </font></td>
              <TD align=right><FONT color=red
                        size=1>&nbsp;</FONT></TD>
              <td><input type=checkbox checked value=y
                        name=offers> &nbsp; </TD>
            </TR>
            <TR>
              <TD width="200" height="25" align=left valign="top" bgcolor="#f4f4f4">&nbsp;<B>Oprettelses aftale: </B></TD>
              <TD align=right>&nbsp;</TD>
              <TD> <TEXTAREA style="FONT-FAMILY: Tahoma, Arial, Verdana" name=agreement rows=10 cols=30> 
                      <?
                      $agreement=mysql_fetch_array(mysql_query("select agreement from sbwmd_config"));
                      echo str_replace("\n","<br>",$agreement["agreement"]);
                      ?>
  </TEXTAREA> </font></TD>
            </TR>
            <TR>
              <TD width="200" height="25" align=left valign="top" bgcolor="#f4f4f4">&nbsp;<B>Acceptere du dette? </B></TD>
              <TD align=right>&nbsp;</TD>
              <TD> <INPUT type=radio value=y
                        name=agreement_conf>
              Ja
              &nbsp; <INPUT type=radio CHECKED
                        value=n name=agreement_conf>
              Nej              &nbsp; </font></TD>
            </TR>
            <TR>
              <TD width="200" height="25" align=left valign="top" bgcolor="#f4f4f4">&nbsp;</font></TD>
              <TD align=right>&nbsp;</TD>
              <TD><INPUT type=submit value=Submit name=Tilføj> &nbsp; <INPUT type=reset value=Nulstil name=reset></TD>
            </TR>
          </TBODY>
        </TABLE>
      </form>
      <?
      }
      ?>
      </td>
  </tr>
</table>
<?
}// end main
include "template.php";
?>
_____

Dette er selve registreringen, men når man klikker på oprettelse inde i mailen kommer denne side ikke frem med det link man får. Den skriver bare "siden kan ikke vises"

Nogen der kan hjælpe?
Avatar billede wetdog Nybegynder
10. juni 2006 - 20:42 #1
denne:
if ( $rs=mysql_fetch_array($rs_query)  )

skal ændres til:
if ( $rs==mysql_fetch_array($rs_query)  )
Avatar billede jakobdo Ekspert
12. juni 2006 - 14:05 #2
Hvis du får fejlen: Siden kan ikke vises, så er det jo tydeligvis en fejl.
Sikker på linket er korrekt?
Har du mulighed for at enable error_reporting ?
Måske det er en fejl i dit script, som desværre ikke vises.
Avatar billede Ny bruger Nybegynder

Din løsning...

Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.

Loading billede Opret Preview
Kategori
Vi tilbyder markedets bedste kurser inden for webudvikling

Log ind eller opret profil

Hov!

For at kunne deltage på Computerworld Eksperten skal du være logget ind.

Det er heldigvis nemt at oprette en bruger: Det tager to minutter og du kan vælge at bruge enten e-mail, Facebook eller Google som login.

Du kan også logge ind via nedenstående tjenester