Jump to content

Username that brings you to Email address.


danjesama

Recommended Posts

Hi Guys,

I have a form adds details to a table and one of them is owner email which takes in an email address. this in turn displays this email address on the form. 

What I am looking to do is for the form have the user just put in there username and the email address is automatically attached at the end(as all the details after@ in the email address will be the same). Then when the table is displaying the email address it just displays the username which when clicked still brings you to a new email to that email address.

Images:

50cd76660a825630c83798472aadb2ee.png so here it would be just username and @whatver.com is always on the form

d7706b38bacd14a3d9c8249ede0bb68f.png  and here it just displays the username so dmurran instead of the whole email address.

here is the code for the table:


// display data in table




echo "<table align='center' border='1' cellpadding='2' class='footable mdl-data-table mdl-js-data-table mdl-data-table--selectable mdl-shadow--4dp full-width'>";

echo "<tr> <th>ID</th> <th>Administration Console</th> <th>Product Version</th> <th>Platform</th> <th>Database</th> <th>Owner</th> <th>Status</th> <th></th> <th></th></tr>";



// loop through results of database query, displaying them in the table

while($row = mysql_fetch_array( $result )) {



// echo out the contents of each row into a table

echo "<tr>";

echo '<th>' . $row['id'] . '</th>';

echo '<td><a href="'.$row['curl'].'">'.$row['curl'].'</a></td>';

echo '<td>' . $row['pversion'] . '</td>';

echo '<td>' . $row['platform'] . '</td>';

echo '<td>' . $row['dversion'] . '</td>';

echo '<td><a href="mailto:'.$row['email'].'">' . $row['email'].'</a></td>';

echo '<td>' . $row['status'] .'</td>';


echo '<td><a href="php/edit.php?id=' . $row['id'] . '">Edit</a></td>';

echo '<td><a onclick="javascript:confirmationDelete($(this));return false;" href="php/delete.php?id=' . $row['id'] . '"onclick="return confirm("Do you want to delete this?")">Delete</a></td>';

echo "</tr>";

}





// close table>

echo "</table>";

?>

 

and here is the form:

<?php

/*

NEW.PHP

Allows user to create a new entry in the database

*/



// creates the new record form

// since this form is used multiple times in this file, I have made it a function that is easily reusable

function renderForm($curl, $pversion, $platform, $dversion, $email, $status, $error)

{

?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">

<html>

<head>
    <link rel="stylesheet" type="text/css" href="../css/style.css"> 
    
    <link href='../css/bootstrap.cs' rel='stylesheet'>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
    <script src='../js/bootstrap.js'></script>

<title>New Repo</title>

</head>

<body>
    <div id="page-wrap">
    
     <center><a href="https://repo-project-danielmurran.c9users.io/view.php"><img src="../images/logo.png" alt="what image shows" height="90" width="300"></a></center>
     
     <h1>GCS Reproduction Environment</h1></br>
     
     <button  type="button" onclick="window.location='https://repo-project-danielmurran.c9users.io/view.php'">Home</button>
    
    <hr/>
    
    <h2> Add Reproduction</h2>
    
    

<?php

// if there are any errors, display them

if ($error != '')

{

echo '<div style="padding:4px; border:1px solid red; color:red;">'.$error.'</div>';

}

?>



    
<form  action="" method="post">

<div id="bform">
<table id="maintable" border='1' cellpadding='10'>
     <thead> 
        <tr>
<th>Repoduction Console URL: *<td><input type="text" name="curl" value="<?php echo $curl; ?>" /></td> </tr>

<th>Product Version: *<td> <input type="text" name="pversion" value="<?php echo $pversion; ?>" /></td></tr>

<th>Platform: * <td><input type="text" name="platform" value="<?php echo $platform; ?>" /></td></tr>

<th>Database: * <td><input type="text" name="dversion" value="<?php echo $dversion; ?>" /></td></tr>

<th>Owner Emaill: *  <td><input type="email" name="email" value="<?php echo $email; ?>" /> </td></tr>

<th>Repo Status: * <td><input type="text" name="status" value="<?php echo $status; ?>" /></td></tr>

</table>
* required

<input type="submit" name="submit" value="Submit">


</div>

</form>

</div>

</body>

</html>

<?php

}

// connect to the database

include('../php/connect-db.php');


// check if the form has been submitted. If it has, start to process the form and save it to the database

if (isset($_POST['submit']))

{

// get form data, making sure it is valid

$curl = mysql_real_escape_string(htmlspecialchars($_POST['curl']));

$pversion = mysql_real_escape_string(htmlspecialchars($_POST['pversion']));

$platform = mysql_real_escape_string(htmlspecialchars($_POST['platform']));

$dversion = mysql_real_escape_string(htmlspecialchars($_POST['dversion']));

$email = mysql_real_escape_string(htmlspecialchars($_POST['email']));

$status = mysql_real_escape_string(htmlspecialchars($_POST['status']));



// check to make sure all fields are entered

if ($curl == '' || $pversion == '' || $platform == '' || $dversion == '' || $email == '' || $status == '')

{

// generate error message

$error = 'ERROR: Please fill in all required fields!';



// if either field is blank, display the form again

renderForm($curl, $pversion, $platform, $dversion, $email, $status, $error);

}

else

{

// save the data to the database

mysql_query("INSERT INTO players SET curl='$curl', pversion='$pversion', platform='$platform', dversion='$dversion', email='$email', status='$status'")


or die(mysql_error());



// once saved, redirect back to the view page

header("Location: ../view.php");

}

}

else

// if the form hasn't been submitted, display the form

{

renderForm('','','','','','','');

}

?>

 

I tried to cut off the end of the email but it was not bringing me to the email address anymore.

 

Any help is appreciated.

 

Thanks!

Link to comment
Share on other sites

If the only thing that changes is the account name, and the domain name is always the same, then it sounds like you should change that field to just ask for the account name and not the entire email address, and add the domain to it whenever you need the email address.  You can make that obvious in the form by writing the domain after the field, e.g.:

 

<input name="email">@domain.com

Link to comment
Share on other sites

14 hours ago, justsomeguy said:

Hey, that is perfect for the new entry for the form, is there a way to just display the username and not @domain.com in the table though? and that it will still bring you to the email address once clicked

 

 

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...