Jump to content

Recommended Posts

On my index page, I want people to register a url. Here is the code I have:

<INPUT size=25 name=url value="<?if(($url!="")and($url!="http://")){print $url;}else{print "http://";}?>">

For some brilliant reason, url after registration defaults to AND gets stored as MY url....not the individual registering at my site.

I don't think there's any problem with the above code, but I don't know...I think I'm going crazy.

If someone has ideas of what I could've done by mistake...please let me know.
Link to comment
https://forums.phpfreaks.com/topic/10221-php-variable-always-defaults-to-siteurl/
Share on other sites

I'm sorry if this looks obnoixous. I don't see an attachment option for the forum, so I'm just going to paste the index page below.

<?
require('error_inc.php');
require('config_inc.php');

if($r_ses == ""){
$res = mysql_query("select * from user where acctype!=1 order by id asc");
for($i = 0; $i < mysql_num_rows($res); $i++){
$id = mysql_result($res,$i,"id");
$acctype = mysql_result($res,$i,"acctype");

$selcount = mysql_result(mysql_query("select distinct(count(ido)) from user where ido=$id order by ido asc"),0);
$selrefhowmany = mysql_result(mysql_query("select refhowmany from acctype where id=$acctype"),0);

$selcount = $selcount+1;
if($selcount < $selrefhowmany){
$selrefid[] = $id;
} else {
$selrefid[] = 0;
}
}

$selrefidu = array();
for ($i = 0; $i < count($selrefid); $i++){
if (!in_array($selrefid[$i], $selrefidu)){
$selrefidu[] = $selrefid[$i];
}
}
shuffle($selrefidu);

while (list($kk, $vv) = each($selrefidu)){
if($vv != 0){
header("location: ./mem_page.php?r=".$vv);
exit;
}
}
}
if(getenv(HTTP_CLIENT_IP)){
$ip=getenv(HTTP_CLIENT_IP);
} else {
$ip=getenv(REMOTE_ADDR);
}

function adv_print($id){
global $t_user;
global $it;

$query="select id,ido,url,title from ".$t_user." where id=".$id;
$result=mysql_query($query);
if(mysql_num_rows($result)!=0){
$it++;
$ido=mysql_result($result,0,"ido");
?>
<TR>
<TD bgcolor="#ffffff">
<FONT face=verdana size=-1> <?print $it;?></FONT>
</TD>
<TD width="96%" bgcolor="#ffffff">
<FONT face=verdana size=-1>
<A target=_blank href="run.php?n=<?print $it;?>"><?print mysql_result($result,0,"title");?></A>
</FONT>
</TD>
</TR>
<?
if($ido!=0){
adv_print($ido);
}
}
}

$error=false;
if($REQUEST_METHOD=="POST"){
for($i=0;$i<=$ad_num;$i++){
${"ad$i"}=intval(${"ad$i"});
if(${"ad$i"}==""){
$error=true;
$err_str[]=$vars["incorr_code_ad"]." $i";
}
if(${"ad$i"}!=$code_ses[$i]){
$error=true;
$err_str[]=$vars["incorr_code_ad"]." $i";
}
}
//etopbizscripts
$name=htmlspecialchars($name);
if($name==""){
$error=true;
$err_str[]=$vars["your_name"];
}

$adtext=htmlspecialchars($adtext);
if($adtext==""){
$error=true;
$err_str[]=$err[2];
}

$url=htmlspecialchars($url);
if($url==""){
$error=true;
$err_str[]=$err[1];
}

$email=htmlspecialchars($email);
if($email==""){
$error=true;
$err_str[]=$vars["incorr_email"];
}

$maillist=intval($maillist);
if(($maillist!=0)and($maillist!=1)){
$error=true;
}

$query="select id from ".$t_user." where email=\"".$email."\"";
$result=mysql_query($query);
if(mysql_num_rows($result)!=0){
$error=true;
$err_str[]=$err[4];
}

$signip = mysql_result(mysql_query("select value from vars where name='mtsingupsip'"), 0);
if ($signip == 0){
$signupflag = mysql_result(mysql_query("select count(*) from user where ip='$ip'"), 0);
if ($signupflag>=1){
$err_str[]= 'Your registration IP is already in our system.<br>';
$error=true;
}
}

$banflag=0;
$banflag1 = mysql_result(mysql_query("select count(*) from ban where ban_content='$email1' and ban_type=1"), 0);
$banflag2 = mysql_result(mysql_query("select count(*) from ban where ban_content='$ip' and ban_type=2"), 0);
if ($banflag1>=1){
$err_str[]= 'Your registration Email is banned in our system.<br>';
$error=true;
}
if($banflag2>=1){
$err_str[]= 'Your registration IP is banned in our system.<br>';
$error=true;
}

if($error==false){
mt_srand((double)microtime()*1000000);
$pass=mt_rand(1000000,9999999);
srand((double)microtime()*1000000);
$ac = rand(1000, 10000);
$url = $_SERVER['SERVER_NAME'];
$root = $url.$_SERVER['PHP_SELF'];
$root = str_replace("index.php","",$root);
$root = "http://".$root;

$query="insert into ".$t_user." set name=\"".$name."\", email=\"".$email."\", pass=\"".$pass."\", ac=\"".$ac."\", ido=".$r_ses.", url=\"".$url."\", title=\"".$adtext."\", mail_list=\"".$maillist."\", ip=\"".$ip."\", date=".mktime()." ";
if(!@mysql_query($query)){
$error=true;
$err_str[]=$err[3];
} else {
$ac=$ac."&ref=".$r;
$body_s=preg_replace ("[\[id\]]",mysql_insert_id(), $body[1]);
$body_s=preg_replace ("[\[name\]]",$name, $body_s);
$body_s=preg_replace ("[\[email\]]",$email, $body_s);
$body_s=preg_replace ("[\[pass\]]",$pass, $body_s);
$body_s=preg_replace ("[\[ac\]]",$ac, $body_s);
$body_s=preg_replace ("[\[siteurl\]]",$root, $body_s);

@mail($email,$vars["subject"],$body_s,"From: \"".$vars["from_name"]."\" <".$vars["from_email"].">");

require('header_inc.php');
?>
<center><p><?print $vars["account_created"];?></p></center><br><br>
<?
require('footer_inc.php');
exit;
}
}
}
require('header_inc.php');
require('incbanner.php');
bannerads();
?>
<script language=javascript>
<!--
function validateall(){
<?php
for($i=0;$i<=($ad_num-$it);$i++){
if($i == 0){
?>
if (document.regform.ad0.value == "") {
alert('<?print $vars["incorr_sp_code"]?>'+' ');
document.regform.ad0.focus;return;
}
<?php
}
if($i == 1){
?>
if (document.regform.ad1.value == "") {
alert('<?print $vars["incorr_code_ad"]?>'+' 1');
document.regform.ad1.focus;return;
}
<?php
}
if($i == 2){
?>
if (document.regform.ad2.value == "") {
alert('<?print $vars["incorr_code_ad"]?>'+' 2');
document.regform.ad2.focus;return;
}
<?php
}
if($i == 3){
?>
if (document.regform.ad3.value == "") {
alert('<?print $vars["incorr_code_ad"]?>'+' 3');
document.regform.ad3.focus;return;
}
<?php
}
if($i == 4){
?>
if (document.regform.ad4.value == "") {
alert('<?print $vars["incorr_code_ad"]?>'+' 4');
document.regform.ad4.focus;return;
}
<?php
}
if($i == 5){
?>
if (document.regform.ad5.value == "") {
alert('<?print $vars["incorr_code_ad"]?>'+' 5');
document.regform.ad5.focus;return;
}
<?php
}
if($i == 6){
?>
if (document.regform.ad6.value == "") {
alert('<?print $vars["incorr_code_ad"]?>'+' 6');
document.regform.ad6.focus;return;
}
<?php
}
if($i == 7){
?>
if (document.regform.ad7.value == "") {
alert('<?print $vars["incorr_code_ad"]?>'+' 7');
document.regform.ad7.focus;return;
}
<?php
}
if($i == 8){
?>
if (document.regform.ad8.value == "") {
alert('<?print $vars["incorr_code_ad"]?>'+' 8');
document.regform.ad8.focus;return;
}
<?php
}
if($i == 9){
?>
if (document.regform.ad9.value == "") {
alert('<?print $vars["incorr_code_ad"]?>'+' 9');
document.regform.ad9.focus;return;
}
<?php
}
}
?>
if (document.regform.name.value == "") {
alert('<?print $vars["your_name"]?>');
document.regform.name.focus;return;
}
if (document.regform.email.value == ""){
alert('<?print $vars["incorr_email"]?>');
document.regform.email.focus;return;
}
if (document.regform.email.value != document.regform.email1.value){
alert('<?print $vars["incorr_email"]?>');
document.regform.email1.focus;return;
}
if (!document.regform.terms.checked) {
alert('<?print $vars["read_terms"]?>');
document.regform.terms.focus;return;
}
document.regform.submit();
}
//-->
</SCRIPT>
<TABLE cellSpacing=5 cellPadding=0 width="100%" border=0>
<TBODY>
<TR>
<TD vAlign=top>
<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
<TBODY>
<TR>
<TD>
<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
<TBODY>
<TR align="center">
<TD vAlign=top width="80%">
<TABLE cellSpacing=0 cellPadding=4 width=95% border=0 bgColor=#4d99e5>
<TBODY>
<TR>
<TD noWrap bgColor=#2C86E0 height=20 colspan="2">
<FONT face=verdana color=white size=-1><B>SPONSOR AD</B></FONT>
</TD>
</TR>
</TBODY>
</TABLE>
<TABLE cellSpacing=0 cellPadding=3 width=95% border=0>
<TBODY>
<TR>
<TD bgcolor="#eeeeee" height="25" align="center"><b>
<?
$query="select * from user_spadv where status='Active' order by rand() limit 1";
$result=mysql_query($query);
$num_rows = @ mysql_num_rows ($result);
$query="select * from ".$t_sponsors;
$result=mysql_query($query);
while($row=mysql_fetch_array($result)){
$adv[$row["ad"]]=$row["title"];
}
$sltrnd = rand(0,$ad_num);
if($sltrnd == 0 || $num_rows == null){
?>
<FONT face=verdana size=-1>
<A name="join" target=_blank href="run.php?n=0">
<?
$slspadlimit = mysql_result(mysql_query("select chrallow from $t_sponsors where ad=0"),0);
$ctad = strlen("$adv[0]") >= $slspadlimit ? substr("$adv[0]", 0, $slspadlimit) . "..." : "$adv[0]";
print $ctad;
} else {
$query="select * from user_spadv where status='Active' order by rand() limit 1";
$result=mysql_query($query);
while($row=mysql_fetch_array($result)){

echo "<FONT face=verdana size=-1>\n";
echo "<A name=\"join\" target=_blank href=runsp.php?n=0&id=".$row["id"].">\n";

$slspadlimit = mysql_result(mysql_query("select chrallow from adv_pkg where id=".$row["pkg"]),0);
$ctad = strlen($row["spadtext"]) >= $slspadlimit ? substr($row["spadtext"], 0, $slspadlimit) . "..." : $row["spadtext"];
if ($row["currentclicks"]==1) {
$query="UPDATE user_spadv SET status='Expired', currentclicks='0' WHERE id =".$row["id"];
$result=mysql_query($query);
}else if($row["currentclicks"]!=-1){
$query="UPDATE user_spadv SET currentclicks=".($row["currentclicks"]-1)." WHERE id =".$row["id"];
$result=mysql_query($query);
}
print $ctad;
}
}
?>
</A>
</FONT>
</TD>
</TR>
</TBODY>
</TABLE><br><br>

<TABLE cellSpacing=1 cellPadding=2 width=95% border=0 height=20 bgColor=#4d99e5>
<TBODY>
<TR>
<TD noWrap bgColor=#1F78D1 height=20 rowSpan=2>
<FONT face=verdana color=white size=-1><B>MEMBER ADS</B></FONT>
</TD>
</TR>
</TBODY>
</TABLE>
<TABLE cellSpacing=1 cellPadding=4 width=95% border=0 bgColor=#4d99e5><tr><td>

<TBODY>
<?
adv_print($r_ses);
for($i=1;$i<=($ad_num-$it);$i++){
?>

</td></tr>
<TR bgcolor="#ffffff" height="20">
<TD bgcolor="#ffffff" height="20">
<FONT face=verdana size=2> <?print $i+$it;?></FONT>
</TD>
<TD width="100%" bgcolor="#ffffff" height="20">
<FONT face=verdana size=2>
<A target=_blank href="run.php?n=<?print $i+$it;?>">
<?
$slspadlimit = mysql_result(mysql_query("select chrallow from $t_sponsors where ad=$i+$it"),0);
$ctad = strlen("$adv[$i]") >= $slspadlimit ? substr("$adv[$i]", 0, $slspadlimit) . ".." : "$adv[$i]";
print $ctad;
?>
</A>
</FONT>
</TD>
</TR>

<?
}
?>

</TBODY>
</TABLE>

<form name="regform" method="post" action="" >
<TABLE cellSpacing=0 cellPadding=2 width=95% border=0>
<TBODY>
<TR>
<TD noWrap bgColor=#4d99e5 height=25 rowSpan=2>
<FONT face=verdana color=white size=-1>
<B>AD CODES <font color="#000000">(a unique code is required from each ad shown above)</font></B>
</FONT>
</TD>
</TR>
</TBODY>
</TABLE>

<TABLE cellSpacing=0 cellPadding=4 width=95% bgColor=#4d99e5 border=0>
<TBODY>
<TR>
<TD>
<TABLE cellSpacing=0 cellPadding=4 width="100%"
bgColor=#E1EBFB border=0>
<TBODY>
<TR>
<TD>
<TABLE cellSpacing=0 cellPadding=0 width="100%"
border=0>
<TBODY>
<TR>
<TD width="25%" rowSpan=2>
<DIV align=center><FONT face=verdana
size=-2><b>Sponsor<BR>Ad</b></FONT><BR><INPUT size=7
name=ad0 value="<?print $ad0;?>"> </DIV>
<DIV align=center></DIV></TD>
<?php
//for($i=0;$i<=($ad_num-$it);$i++){
for($i=0;$i<=($ad_num-1);$i++){
if($i == 0){
?>
<TD width="25%">
<DIV align=center><FONT face=verdana size=-2>1st
Ad<BR></FONT><INPUT size=7 name=ad1 value="<?print $ad1;?>">
</DIV></TD>
<?php
}
if($i == 1){
?>
<TD width="25%">
<DIV align=center><FONT face=verdana size=-2>2nd
Ad</FONT><BR><INPUT size=7 name=ad2 value="<?print $ad2;?>">
</DIV></TD>
<?php
}
if($i == 2){
?>
<TD width="25%">
<DIV align=center><FONT face=verdana size=-2>3rd
Ad<BR></FONT><INPUT size=7 name=ad3 value="<?print $ad3;?>">
</DIV></TD></TR>
<?php
}
?>

<?
if($i == 3){
?> <TR>
<TD width="25%">
<DIV align=center><FONT face=verdana size=-2>4th
Ad</FONT><FONT face=Arial
size=1><BR></FONT><INPUT size=7 name=ad4 value="<?print $ad4;?>">
</DIV></TD>
<?php
}
if($i == 4){
?>
<TD width="25%">
<DIV align=center><FONT face=verdana size=-2>5th
Ad</FONT><FONT face=Arial
size=1><BR></FONT><INPUT size=7 name=ad5 value="<?print $ad5;?>">
</DIV></TD>
<?php
}
if($i == 5){
?>
<TD width="25%">
<DIV align=center><FONT face=verdana size=-2>6th
Ad </FONT><BR><INPUT size=7 name=ad6 value="<?print $ad6;?>">
</DIV></TD></TR>
<?php
}
?>
<?
if($i == 6){
?>
<TR><td></td>
<TD width="25%">
<DIV align=center><FONT face=verdana size=-2>7th
Ad</FONT><FONT face=Arial
size=1><BR></FONT><INPUT size=7 name=ad7 value="<?print $ad7;?>">
</DIV></TD>
<?php
}
if($i == 7){
?>
<TD width="25%">
<DIV align=center><FONT face=verdana size=-2>8th
Ad</FONT><FONT face=Arial
size=1><BR></FONT><INPUT size=7 name=ad8 value="<?print $ad8;?>">
</DIV></TD>
<?php
}
if($i == 8){
?>
<TD width="25%">
<DIV align=center><FONT face=verdana size=-2>9th
Ad </FONT><BR><INPUT size=7 name=ad9 value="<?print $ad9;?>">
</DIV></TD>
<?php
}
}
?>
</TR>
</TBODY></TABLE></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE>
<br>
<TABLE cellSpacing=0 cellPadding=1 width=100%
bgColor=#4d99e5 border=0>
<TBODY>
<?php
require('benefits.php');
?>
<tr><td align=center><br><FONT face=verdana size=2 color="red">
<b>
<?
if($error==true){
print join($err_str,"<br>");
}
?>
</b>
<br></td></tr>
<TR>
<TD>
<TABLE cellSpacing=0 cellPadding=2 width="100%"
bgColor=#ffffff border=0>
<TBODY>
<TR bgcolor="#ffffff">
<TD>
<TABLE width="65%" align=center bgcolor="#ffffff">
<TBODY>
<TR bgcolor="#ffffff">
<TD width=200>
<DIV align=right><FONT face=verdana size=2><b>Referred by #:</b></FONT></DIV></TD>
<TD width=197><?print $r_ses;?></TD></TR>
<TR>
<TD width=200>
<DIV align=right><FONT face=verdana size=2>Your IP address:</FONT></DIV></TD>
<TD width=197><?print $_SERVER['REMOTE_ADDR'];?></TD></TR>
<TR>
<TD width=200>
<DIV align=right><FONT face=verdana size=2>Name:</FONT></DIV></TD>
<TD width=197><INPUT size=25 name=name value="<?print $name;?>">
</TD></TR>
<TR>
<TD width=200>
<DIV align=right><FONT face=verdana
size=2>Email:</FONT> </DIV></TD>
<TD width=197><INPUT size=25 name=email value="<?print $email;?>">
</TD></TR>
<TR>
<TD width=200>
<DIV align=right><FONT face=verdana
size=2>Confirm E-mail address:</FONT> </DIV></TD>
<TD width=197><INPUT size=25 name=email1 value="<?print $email;?>">
</TD></TR>
<TR>
<TD width=200>
<DIV align=right><FONT face=verdana size=2>Text
Ad:<BR><FONT color=red size=1>(max. 60
characters)</FONT></FONT></DIV></TD>
<TD width=197><INPUT maxLength=60 size=30
name=adtext value="<?print $adtext;?>"> </TD></TR>
<TR>
<TD width=200>
<DIV align=right><FONT face=verdana size=2>Your
URL:</FONT> </DIV></TD>
<TD width=197><INPUT size=25
name=url value="<?if(($url="")and($url="http://")){print $url;}else{print "http://";}?>"> </TD></TR>
<TR>
<TD colSpan=2>
<CENTER><FONT face=arial size=1><B><FONT
face=verdana size=-2><BR>Your Password will be
automatically generated<BR>and sent to above
email address.</FONT></B></FONT>
</CENTER></TD></TR>
<TR>
<TD colSpan=2><BR>
<CENTER>
<TABLE cellSpacing=0 cellPadding=2 width="80%"
border=0 align=center>
<TBODY>
<TR>
<TD vAlign=top><INPUT type=checkbox value=yes
name=terms> </TD>
<TD colspan="2"><FONT face=verdana size=-2>I have read and
agree to the
<A target=_new href="terms.php">Terms of Service</A></FONT> </TD></TR>
<TR>
<TD vAlign=top><INPUT type=checkbox CHECKED
value=1 name=maillist> </TD>
<TD colspan="2"><FONT face=verdana size=-2>Join Mailing
List <font color="red">(receive Admin messages with News Updates)</font></FONT> </TD></TR></TBODY></TABLE>
<P>
<INPUT onclick=validateall(); type=button value="Sign Me Up Now!" name="ok">
<br><br><bR><font face=verdana,arial size=1><a href=http://www.e-topbiz.com target=_new>Powered by ViralDX v2.09</a></font> </P></CENTER></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE></FORM>
<?
tads();
require('footer_inc.php');
?>
I think the problem occurs in this segment of code. (I'm sorry, I've only started to learn php in an attempt to get this site running)

if($error==false){
mt_srand((double)microtime()*1000000);
$pass=mt_rand(1000000,9999999);
srand((double)microtime()*1000000);
$ac = rand(1000, 10000);
$url = $_SERVER['SERVER_NAME'];
$root = $url.$_SERVER['PHP_SELF'];
$root = str_replace("index.php","",$root);
$root = "http://".$root;

It's located about 1/3 of the way through the code.

Someone please help....please
Yeah I was lookingt at you code earlier when you posted it but I got confused looking at it as its a complete mess really and I couldn't find my way through it. But as you have point that block of code above I can see your problem which is here:
[code] $url = $_SERVER['SERVER_NAME'];[/code]
Notice you are setting up $url with the value of $_SERVER['NAME']. This is why you input form always displays you web address in the input field. What you should do is this, change the following:[code] $url = $_SERVER['SERVER_NAME'];
$root = $url.$_SERVER['PHP_SELF'];
$root = str_replace("index.php","",$root);
$root = "http://".$root;[/code] to the following: [code]$root = $_SERVER['SERVER_NAME'] . $_SERVER['PHP_SELF'];
$root = str_replace("index.php", "", $root);
$root = "http://" . $root;[/code]
holy crap! It worked!!!!

I'm interested in tying in another script to access info from the same mysql database. I know I'm probably going to need a hand with some stuff.

If you're interested, give me a shout: troy@conquestmortgages.com

let me know what your rate is, etc.

Thanks again
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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