Jump to content

[SOLVED] PHP HELP


Recommended Posts

you could try having the link something like:

<a href="http://mydomain.com/mypage.php?insert=1

then:

<?php
if(isset($_GET['insert'] && $_GET['insert'] == '1'){
    //sql query here
}

 

If the user is logged in you should be able to get their email address somehow.. is it stored in a session?

Link to comment
Share on other sites

you're code should look something like this:

<?php
if(isset($_GET['insert'] && $_GET['insert'] == '1'){
    $sql = "INSERT INTO `emailists` (`stixy`) VALUE ('" . $username . "')";
        if($sqlres = mysql_query($sql)){
            echo 'email address added';
        }else{
            echo mysql_error();
        }
}
?>

 

with the link:

<a href="http://mydomain.com/mypage.php?insert=1

Link to comment
Share on other sites

My code is

<?php include 'header.php';  // Works.


?>
<div id="content">
<div id="columnsC"><br/>
	<a href="http://www.stixy.com"><img  style="border:0;" src="siteimg/stixy.jpg" alt="stixy"/></a><Br/>
<p>Stixy helps users organize their world on flexible, shareable Web-based bulletin boards called Stixyboards. Unlike most personal productivity or project management software, Stixy doesn't dictate how users should organize their information. Users can create tasks, appointments, files, photos, notes, and bookmarks on their Stixyboards, organized in whatever way makes sense to them. Then they can share Stixyboards with friends, family, and colleagues.</p>
</div>
<div id="columnsD">
<?
/**
* User has already logged in, so display relavent links
*/
if($session->logged_in){
$dbh=mysql_connect ("localhost", "my_username", "my_pass") or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ("my_db"); 
echo "<ul>";
if(isset($_GET['insert'] && $_GET['insert'] == '1'){
    $sql = "INSERT INTO `emailists` (`stixy`) VALUE ('" . $username . "')";
        if($sqlres = mysql_query($sql)){
            echo 'email address added';
        }else{
            echo mysql_error();
        }
}
  $sql = "SELECT stixy FROM emailists";
  if ($result = mysql_query($sql)) {
    if (mysql_num_rows($result)) {
      while ($row = mysql_fetch_assoc($result)) {
        echo "<li>";  echo $row['stixy'] . "</li>";
        
      }
    }
  }
echo "</ul>";

}
else{
?>
<br/>
<p style="border-style: solid;
border-width: 3px;"><b>To Invite people or add yourself to the list you need to either login or if you dont have an account signup</b></p>

<?
}
?>

</div>



<?php include 'sidebar.php'; ?>
<div style="clear: both;"> </div>
</div>
<?php include 'footer.php';  // Works.


?>

Link to comment
Share on other sites

change this part:

if(isset($_GET['insert'] && $_GET['insert'] == '1'){
    $sql = "INSERT INTO `emailists` (`stixy`) VALUE ('" . $username . "')";
        if($sqlres = mysql_query($sql)){
            echo 'email address added';
        }else{
            echo mysql_error();
        }
}

 

to this:

if(isset($_GET['insert']) && $_GET['insert'] == '1'){
    $sql = "INSERT INTO `emailists` (`stixy`) VALUE ('" . $username . "')";
        if($sqlres = mysql_query($sql)){
            echo 'email address added';
        }else{
            echo mysql_error();
        }
}

you had a missed out ) after the isset()

Link to comment
Share on other sites

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.