Jump to content

jcl43

Members
  • Posts

    12
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

jcl43's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Ok, nm i got it working. I replaced echo "<p>" . $results . "</p>"; with... echo "<p>" . $row['title']. $row['deadline'] . $row['descrip'] . $row['link'] . $row['postDate'] . "</p>"; Now it just needs some better formatting....thanks anyways!
  2. Thanks, I added a space after Opportunity and that got rid of the error. However, it is now only outputting Resource id #3 instead of the contents of $results. Should I not be using my_sql_fetch_array? Thanks again
  3. Thanks for the previous help, I am now getting an error Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /d3/home/univ/cis450rb/public_html/index.php on line 194 The code that is trying to run is here: if (!$con) { die('Could not connect: ' . mysql_error()); } @mysql_select_db($dbusername) or die("Unable to select database"); $query = "select * from Opportunity" . "where oppId = 10"; $results = mysql_query( $query, $con ); while ($row = mysql_fetch_array($results)) { echo "<p>" . $results . "</p>"; } The while loop is where the error is being thrown. I know there is something I am missing, but cannot figure it out for the life of me. Any help is appreciated..thanks!
  4. Thanks a lot to you all, it seems to be working. I will report back if I have any need for further help. thanks again edit: btw i am using the myaccount.php method and grabbing session data.
  5. Hi all, I am creating a login system for my site. So far the registration and login both work great, but I am having a problem redirecting a user to the myaccount.php page after a successful login. I was planning on having a link to continue to their profile page and was doing it like so: <?php echo "<h2>Success! You are now logged in " . $_SESSION['username'] . "</h2><br><br>"; ?> <h2>Click here to continue to your profile: <a href="myaccount.php?username However, i am unsure of how to complete the link, or if that is even the correct way to do it. Would it be recommended to use header() instead? And if so how would I implement that in this situation so it doesnt automatically redirect? Thanks in advance for any help!
  6. Ok, I removed userId and made it auto increment. I am still getting syntax error though. This is what the user table looks like: +-----------------+-------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +-----------------+-------------+------+-----+---------+----------------+ | userId | int(11) | | PRI | NULL | auto_increment | | username | varchar(20) | YES | MUL | NULL | | | pword1 | varchar(32) | YES | | NULL | | | pword2 | varchar(32) | YES | | NULL | | | fname | varchar(20) | YES | | NULL | | | lname | varchar(20) | YES | | NULL | | | email | varchar(20) | YES | | NULL | | | activation_code | varchar(50) | YES | | NULL | | | joined | date | YES | | NULL | | | user_activated | int(1) | YES | | NULL | | | schoolid | int(11) | YES | | NULL | | | ascode | int(11) | YES | | NULL | | | emphcode | int(11) | YES | | NULL | | | notifId | int(11) | YES | | NULL | | | externCode | int(1) | YES | | NULL | | +-----------------+-------------+------+-----+---------+----------------+ 15 rows in set (0.00 sec) Here is the error I am getting now: You have an error in your SQL syntax near ' d41d8cd98f00b204e9800998ecf8427e, , , , 6374, now(), 1, , , )' at line 1 This is what is output by echoing $command: INSERT INTO CUser(username, pword2, fname, lname, email, activation_code,joined, user_activated, schoolId, asCode, emphcode)VALUES(, d41d8cd98f00b204e9800998ecf8427e, , , , 6374, now(), 1, , , ) I am wondering why the values being inserted are blank, let me know if you can think of what I am doing wrong. I appreciate it! Thanks
  7. Ok, so I have made some progress and was hoping someone could help out with my new issues. I changed the setup a bit, instead of the form action calling register.php it calls $_SERVER [php_SELF]. This works, the system sends an email when registering, but I get a mysql error "Duplicate entry '0' for key 1" on the next page. The entries are not being added to db, yet it also says successfully registered, and I get an email with the correct activation link etc. I decided to echo $command like suggested before and this is what it output: INSERT INTO CUser(userId, pword2, fname, lname, email,activation_code,joined, user_activated, schoolId, asCode, emphcode)VALUES('', 'd41d8cd98f00b204e9800998ecf8427e', '', '', '', '1713', now(), '1', '', 'as', 'emph') It doesnt seem as if the query is correct. If anyone could help out I would greatly appreciate it!
  8. Thank you, here is the form code: <form name="register" method="post" action="register.php"> <p> Choose a user name: <br> <input name="userId" type="text" id="userId" value=""> </p> <br> <p> Choose a password and enter it twice: <br> Passwords must be at least 6 characters and contain only alphanumerics <br><br> <input name="pword1" type="password" id="pword1" value=""> <input name="pword2" type="password" id="pword2" value=""> </p> <br> <p> First Name: <br> <input name="fname" type="text" id="fname" value=""> </p> <br> <p> Last Name: <br> <input name="lname" type="text" id="lname" value=""> </p> <br> <p> Enter a valid email address:<br> <input name="email" type="text" id="email" value=""> <br><br> Note: You will be sent an activation link at the<br> email address you provide. </p><br><br> <h2><a href="#">Tell us about yourself</a></h2><br> <p> What school do you attend? </p> <br> California State University: <select name ="CSU"> <option value ="">Choose a school</option> <option value ="bakersfield">Bakersfield</option> <option value ="channelislands">Channel Islands</option> <option value ="chico">Chico</option> <option value ="dominguezhills">Dominguez Hills</option> <option value ="eastbay">East Bay</option> <option value ="fresno">Fresno</option> <option value ="fullerton">Fullerton</option> <option value ="humboldt">Humboldt</option> <option value ="longbeach">Long Beach</option> <option value ="csulosangeles">CSU Los Angeles</option> <option value ="maritime">Maritime Academy</option> <option value ="montereybay">Monterey Bay</option> <option value ="northridge">Northridge</option> <option value ="pamona">Pamona</option> <option value ="sacramento">Sacramento</option> <option value ="sanbernadino">San Bernadino</option> <option value ="csusandiego">CSU San Diego</option> <option value ="csusanfrancisco">CSU San Francisco</option> <option value ="sanjose">San Jose</option> <option value ="sanluisobispo">San Luis Obispo</option> <option value ="sanmarcos">San Marcos</option> <option value ="sonoma">Sonoma</option> <option value ="stanislaus">Stanislaus</option> </select> <br><br><br><center>Or</center><br><br> University of California: <select name="UC"> <option value ="">Choose a school</option> <option value ="berkely">Berkely</option> <option value ="davis">Davis</option> <option value ="irvine">Irvine</option> <option value ="uclosangeles">Los Angeles</option> <option value ="merced">Merced</option> <option value ="riverside">Riverside</option> <option value ="ucsandiego">San Diego</option> <option value ="ucsanfrancisco">San Francisco</option> <option value ="santabarbara">Santa Barabara</option> <option value ="santacruz">Santa Cruz</option> </select> <br><br><br> <p> Please tell us your area of study and emphasis <br><br> This will help us bring you the most relevant infomation in order to provide the best access to all research opportunities. <br><br> </p> Note: We are currently limited to students enrolled in the STEM fields of research. <br><br> <select name="areaofstudy"> <option value ="">Choose an area of study</option> <option value ="compsci">Computer Science</option> <option value ="math">Mathematics</option> <option value ="physicalscience">Physical Sciences</option> <option value ="socialsciane">Social/Behavioral Sciences</option> <option value ="lifescience">Life Sciences</option> <option value ="geosci">Geo Sciences</option> <option value ="engineering">Engineering</option> <option value ="genetics">Genetics</option> </select> <br><br> Emphasis: <br> <input name="emph" type="text" id="emph" value=""> </p> <br><br> Please enter the numeric code below into the text box <br><br> This is help protect against automated spam registration <br><br> <input name="user_code" type="text" size="10"> <img src="pngimg.php" align="middle"> <br><br> <input name="register" type="submit" class="login" value="Register"> </form> It is on register.php along with the code I previously posted. It comes after the php code. Is that normal practice? Thanks again for your time
  9. Hi thanks for the help, I am unable to echo anything. Even if i take out all html and code except the $_Post form action and echo. How would you go about doing that? Sorry to sound so naive...any help is appreciated thanks
  10. Hi all, I am working on a site that requires registration, and login to access certain content. I am having trouble debugging the code as no errors pop up when i hit register, and nothing happens on the backend. The php code that I have so far is here: <?php session_start(); include ('dbc.php'); if ($_POST['submit'] == 'register') { if (strlen($_POST['email']) < 5) { die ("Incorrect email. Please enter valid email address.."); } if (strcmp($_POST['pword1'],$_POST['pword2']) || empty($_POST['pword1']) ) { //die ("Password does not match"); die("ERROR: Password does not match or is empty.."); } if (strcmp(md5($_POST['user_code']),$_SESSION['ckey'])) { die("Invalid code entered. Please enter the correct code as shown in the Image"); } $rs_duplicates = mysql_query("select userId from CUser where email='$_POST[email]'"); $duplicates = mysql_num_rows($rs_duplicates); if ($duplicates > 0) { //die ("ERROR: User account already exists."); header("Location: register.php?msg=ERROR: User account already exists.."); exit(); } $username = $_Post['userId']; $md5pass = md5($_POST['pass2']); $fname = $_Post['fname']; $lname = $_Post['lname']; $email= $_Post['email']; $activcode = rand(1000,9999); $joined = now(); $activated = 1; $school = $_Post['CSU']; $as = $_Post['areaofstudy']; $emph = $_Post['emph']; $server = $_SERVER['HTTP_HOST']; $host = ereg_replace('www.','',$server); $command = "INSERT INTO CUser". "(userId, pword2, fname, lname, email,activation_code,". "joined, user_activated, schoolId, asCode, emphcode)". "VALUES". "('$username', '$md5pass', '$fname', '$lname', '$email', '$activcode', ". "'$joined', '$activated', '$school', 'as', 'emph')"; mysql_query($command) or die(mysql_error()); $message = "Thank you for registering an account with $server. Here are the login details...\n\n User Email: $_POST[email] \n Password: $_POST[pass2] \n Activation Code: $activ_code \n ____________________________________________ *** ACTIVATION LINK ***** \n Activation Link: http://$server/activate.php?usr=$_POST[email]&code=$activ_code \n\n _____________________________________________ Thank you. This is an automated response. PLEASE DO NOT REPLY. "; mail($_POST['email'] , "Login Activation", $message, "From: \"Auto-Response\" <notifications@$host>\r\n" . "X-Mailer: PHP/" . phpversion()); unset($_SESSION['ckey']); echo("Registration Successful! An activation code has been sent to your email address with an activation link..."); exit; } ?> The site can be found at www.humboldt.edu/~cis450rb the registration button is the only live link and takes you to the register.php which is the code posted above. If anybody can help out I would greatly appreciate it! Thanks in advance for your time
  11. Its a trigger i wrote to update users profile when there is a new post they have subscribed to. I am trying to get the school to update to version 5, i dont think there would be a work around. Thanks for your time though!
  12. Hello all, I have a database running on my school's server and it is MySQL version 3.23. I need to run a trigger that fires when an event happens. I know this is a feature that just came out in the new version and not available in 3.23. I was wondering if there is way to do this without actually using a trigger or some other workaround that has been used to accomplish this or something similar. Thank you all for taking the time to help.
×
×
  • 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.